I am writing a program in VB.NET 2005 that contains a StatusStrip, progress bar, and status label. Each time a file is copied, the progress bar increments and the status label should say "Copying fax # xx of xx." The problem is that the progress bar works fine, but the status label is not displayed until the progress bar finishes. When I stepped through the code, I see that the status label is updated correctly; it just isn't displayed until AFTER the progress bar. I would like for the status label to be displayed and updated at the same time that the progress bar is updated. Does this require threading? If so, can someone please show me how (with code) because I have no clue when it comes to threading. Thanks!
[b]Here's my code:[/b]
Private Sub mnu_ReceiveFaxOn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnu_ReceiveFaxOn.Click
If mnu_ReceiveFaxOn.Checked Then
Exit Sub
Else
mnu_ReceiveFaxOn.Checked = True
mnu_ReceiveFaxOff.Checked = False
sb_Status.Visible = True
pbar_FaxStatus.Value = 0
sbl_FaxStatus.Text = ""
GetNewFaxes()
End If
End Sub
Private Sub GetNewFaxes()
Dim ClmFaxes As New DataTable
Dim BatchNumber As Long
Dim BatchName As String
Dim TotalPages As Integer
Dim SourceFile As String
Dim DestFile As String
Dim FaxCounter As Integer
Dim RecordCount As Integer
Dim PageCount As Integer
Try
GetClmFaxes(m_EmployeeID)
ClmFaxes = LoadClmFaxes()
RecordCount = ClmFaxes.Rows.Count
For FaxCounter = 1 To RecordCount
[b] sbl_FaxStatus.Text = "Copying fax # " & FaxCounter & " of " & RecordCount[/b]
BatchNumber = ClmFaxes.Rows(FaxCounter - 1).Item("BaseID")
BatchName = BatchNumber.ToString("00000000")
TotalPages = ClmFaxes.Rows(FaxCounter - 1).Item("NumPages")
For PageCount = 1 To TotalPages
SourceFile = My.Settings.ClmFaxFromPath & "\" & BatchName & "." & PageCount.ToString("000")
DestFile = My.Settings.ClmFaxTempPath & "\" & BatchName & "." & PageCount.ToString("000")
My.Computer.FileSystem.CopyFile(SourceFile, DestFile)
Next
[b] pbar_FaxStatus.Increment(10)[/b]
Next
Windows.Forms.Cursor.Current = Cursors.Default
Catch ex As System.Exception
My.Application.Log.WriteException(ex)
End Try
End Sub
ASKER