J
John
If I call the "SyncTables" Sub without a Thread all the code works fine and
with the Thread I'm not getting any errors but the ProgressBar & Label
referenced
in the last "Class SyncChartofAcc" no longer updates on the Refesh. I
removed all the Progress loops to simplify the code.
Thanks in advance
John
Public Class WebTimer
Private WithEvents myBackgroundWorker As New
System.ComponentModel.BackgroundWorker
Private Delegate Sub ProgressHandler()
Dim updateHandler As ProgressHandler = Nothing
Private Sub btnSync_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnSync.Click
Dim t As Thread
t = New Thread(AddressOf SyncTables)
t.Start()
End Sub
Private Sub DoWork()
pgbSync.Step = 8
pgbSync.PerformStep()
End Sub
Private Sub SyncTables()
pgbSync.Maximum = 100
updateHandler = New ProgressHandler(AddressOf DoWork)
'Call Class
Dim SyncChart As New SyncChartOfAcc
SyncChart.DoAccountQueryRq("US", 5, 0, O, qbFileLoc, CompID)
'This Progress update is working under Thread
If pgbSync.InvokeRequired Then
Invoke(updateHandler)
Else
pgbSync.PerformStep()
End If
End Sub
End Class
Public Class SyncChartOfAcc
Public Sub DoAccountQueryRq(ByVal country As String, ByVal majorVersion As
Short, ByVal minorVersion As Short _
, ByVal O As Integer, ByVal qbFileLoc As
String, ByVal CompID As String)
'This Progress update is not working under Thread
Dim prg As ProgressBar = WebTimer.pgbSegmentSync
Dim lblProg As Label = WebTimer.lblSyncSegPrg
prg.Maximum = 100
prg.Step = 1
lblProg.Text = "Getting Chart of Accounts"
WebTimer.Refresh()
'loops removed to simplify
prg.PerformStep()
lblProg.Text = "Processing Account Number " & (QBList.Count) - c
WebTimer.Refresh()
End Sub
End Class
with the Thread I'm not getting any errors but the ProgressBar & Label
referenced
in the last "Class SyncChartofAcc" no longer updates on the Refesh. I
removed all the Progress loops to simplify the code.
Thanks in advance
John
Public Class WebTimer
Private WithEvents myBackgroundWorker As New
System.ComponentModel.BackgroundWorker
Private Delegate Sub ProgressHandler()
Dim updateHandler As ProgressHandler = Nothing
Private Sub btnSync_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnSync.Click
Dim t As Thread
t = New Thread(AddressOf SyncTables)
t.Start()
End Sub
Private Sub DoWork()
pgbSync.Step = 8
pgbSync.PerformStep()
End Sub
Private Sub SyncTables()
pgbSync.Maximum = 100
updateHandler = New ProgressHandler(AddressOf DoWork)
'Call Class
Dim SyncChart As New SyncChartOfAcc
SyncChart.DoAccountQueryRq("US", 5, 0, O, qbFileLoc, CompID)
'This Progress update is working under Thread
If pgbSync.InvokeRequired Then
Invoke(updateHandler)
Else
pgbSync.PerformStep()
End If
End Sub
End Class
Public Class SyncChartOfAcc
Public Sub DoAccountQueryRq(ByVal country As String, ByVal majorVersion As
Short, ByVal minorVersion As Short _
, ByVal O As Integer, ByVal qbFileLoc As
String, ByVal CompID As String)
'This Progress update is not working under Thread
Dim prg As ProgressBar = WebTimer.pgbSegmentSync
Dim lblProg As Label = WebTimer.lblSyncSegPrg
prg.Maximum = 100
prg.Step = 1
lblProg.Text = "Getting Chart of Accounts"
WebTimer.Refresh()
'loops removed to simplify
prg.PerformStep()
lblProg.Text = "Processing Account Number " & (QBList.Count) - c
WebTimer.Refresh()
End Sub
End Class