Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9029775
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T07:19:35+00:00 2026-06-16T07:19:35+00:00

I am trying to create a dialog box that shows the process of loading

  • 0

I am trying to create a dialog box that shows the process of loading certain bill data to Word from a WPF VB.NET app. The problem is that the WPF UI is not updating to show the change.

WPF Code is:

    <StackPanel Grid.Row="1" HorizontalAlignment="Center" VerticalAlignment="Center" >
        <TextBlock Name="StatusDisplayTextBlock" Text="Printing 30 of 40 to document......" FontSize="20"/>
        <ProgressBar Name="PrintProgressBar1" Height="30" Width="400" Margin="0,10,0,0"/>
    </StackPanel>

VB.NET Code:

Imports Microsoft.Office.Interop

Public Class PrintingToDocx
    Dim IsWorkDone As Boolean = False
    Public Enum BillPrintMode
        InOne = 0
        Seperate = 1
    End Enum

    Private BrowserBills As New List(Of Classes.BillsNS.BilBrowserClass)
    Private Bills As New List(Of Classes.BillsNS.BillClass)
    Private PrintMode As BillPrintMode

    Private Sub PrintingToDocx_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles Me.Closing
        If IsWorkDone = False Then
            e.Cancel = True
        End If
    End Sub

    Public Sub New(ByVal BrowserBills As List(Of Classes.BillsNS.BilBrowserClass), ByVal Mode As BillPrintMode)
        InitializeComponent()
        Me.BrowserBills = BrowserBills
        PrintMode = Mode
    End Sub

    Private Sub Window_Loaded(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles MyBase.Loaded
        GetBills()
        If PrintMode = BillPrintMode.InOne Then
            PrintInOne()
            ' IsWorkDone = True
        Else
            Dim count As Integer = 0
            For Each k In Bills
                count = count + 1
                StatusDisplayTextBlock.Text = "Writing Bill " & count & " of " & Bills.Count & " to WORD....."
                DataAccessModuleNS.Reports.PrintaBill(k)
            Next
            IsWorkDone = True
        End If
        Me.Close()
    End Sub

    Private Sub GetBills()
        Me.Focus()
        StatusDisplayTextBlock.Text = "Reading Bills Data...."
        Dim count As Integer = 1
        For Each k In BrowserBills
            Bills.Add(DataAccessModuleNS.Bills.GetBill(k.ID.ToString))
            StatusDisplayTextBlock.Text = "Reading Bill " & count & " of " & BrowserBills.Count & "...."
            'count = count + 1
            count += 1
        Next
    End Sub

    Private Sub PrintInOne()
        Try
            StatusDisplayTextBlock.Text = "Writing Bill " & "0" & " of " & Bills.Count & " to WORD....."

            Dim oWord As Word.Application
            Dim oDoc As Word.Document
            Dim oTable As Word.Table

            Me.Focus()
            'Start Word and open the document template.
            oWord = CreateObject("Word.Application")
            oWord.Visible = False
            oDoc = oWord.Documents.Add
            Dim countBills As Integer = 0
            For Each Bill In Bills
                'To Addressing Fields
                countBills = countBills + 1
                StatusDisplayTextBlock.Text = "Writing Bill " & countBills & " of " & Bills.Count & " to WORD....."

    End Sub
End Class

The problem is like this:
The functionality if working fine, but the UI is not displaying until all the processing is complete. Following is the sample image of taskbar at time of processing to word:
enter image description here

when work is done it is working fine like this:

Following is the Report

enter image description here

EDIT: I now used the background worker, but now the issue is that when the progress changed and I try to update the TextBlock on UI thread I get the error that the action on a different thread cannot be done. Following is the code I used in ProgressChanged event.

Private Sub BackgroundWorker_ProgressChanged(ByVal sender As Object, ByVal e As ProgressChangedEventArgs)
    'Throw New NotImplementedException
    StatusDisplayTextBlock.Text = e.UserState
End Sub

Could you please help me in figuring out how to update the UI thread.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T07:19:36+00:00Added an answer on June 16, 2026 at 7:19 am

    You need to move the logic operation from UI thread…

    Best solution would be to use Backgroundworker class to separate all operations from the UI.
    Good tutorial on that can be found here [link]

    If by change you can use .NET 4.5, you can simlpy use Async-Await pattern [Async in VB]

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to create a hint dialog box that informs the user about
I am trying to create a custom dialog box that displays an image in
I'm trying to create a simple modeless dialog box which I'm creating from my
I'm trying to create a Dialog box that will display a video (quick tutorial)
I'm trying to show a progress dialog while loading information from the web that
I am trying to create a dialog box that will appear only if the
I'm trying to create a modal confirmation dialog box. I'd like it to work
I am trying to create a custom dialog box on the click of an
I'm trying to show a dialog box that says waiting for GPS fix on
I'm trying to create a WiX installer dialog that provides a series of textboxes

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.