When I run my old sync button right away I get 0 update or 20 updates. but with the bg worker it takes long time whether for 0 record or 100 records. I think the problem is with the upper number ( For i As Integer = 1 To 100). Shouldnt the 100 be the actual # of records the class is updating. Please suggest.
here is my class
http://www.e-topco.com/scriptlance/syncslip_2.txt
[SIZE="1"]
[/SIZE]
here is my class
http://www.e-topco.com/scriptlance/syncslip_2.txt
[SIZE="1"]
Code:
Dim objMySlip As New clsSyncSlip()
Dim sResult As Integer
sResult = objMySlip.syncSlipNew(cSessionID)
MsgBox("Total " & sResult & " slip(s) have been updated")
Code:
Private Sub btnSyncNew_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSyncNew.Click
Me.BackgroundWorker1.RunWorkerAsync()
End Sub
Code:
Private Sub BackgroundWorker1_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
Dim worker As System.ComponentModel.BackgroundWorker = DirectCast(sender, System.ComponentModel.BackgroundWorker)
For i As Integer = 1 To 100
'Raise the ProgressChanged event in the UI thread.
worker.ReportProgress(i, i & " iterations complete")
'Perform some time-consuming operation here.
Dim cSessionID = Me.txtSessionID.Text
Dim objMySlip As New clsSyncSlip()
Dim sResult As Integer
sResult = objMySlip.syncSlipNew(cSessionID)
'MsgBox("Total " & sResult & " slip(s) have been updated")
Threading.Thread.Sleep(0)
Next i
MsgBox("done")
End Sub