Adagio
Well-known member
- Joined
- Dec 12, 2005
- Messages
- 162
- Programming Experience
- Beginner
I have the following code:
Basically what is going on is that every 20 seconds this backgroundworker wakes up, does some work, and reports back to GUI
If I let it be (forceUpdate stays false) it reports back as it should. But if I run some code a bit like this:
Then it stops calling the ProgressChanged sub (debug shows that it runs the line with ReportProgress in DoWork sub, but it doesn't seem to go into the code)
Anybody who has any idea what could be wrong here?
VB.NET:
Private Sub BackgroundWorkerUpdateListview_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorkerUpdateListview.DoWork
While TimeUntilUpdate > 0
Threading.Thread.Sleep(500)
TimeUntilUpdate -=1
If forceUpdate = True Then
Exit While
End If
End While
forceUpdate = False
' Do some work
BackgroundWorkerUpdateListview.ReportProgress(100 * rnd)
TimeUntilUpdate = 20
Loop
End Sub
Private Sub bgrLongProcess_ProgressChanged(ByVal sender As Object, ByVal e As System.ComponentModel.ProgressChangedEventArgs) Handles BackgroundWorkerUpdateListview.ProgressChanged
' Report back to GUI
Me.Text = e.ProgressPercentage
End Sub
Basically what is going on is that every 20 seconds this backgroundworker wakes up, does some work, and reports back to GUI
If I let it be (forceUpdate stays false) it reports back as it should. But if I run some code a bit like this:
VB.NET:
Public Sub ButtonClick (...) Handles MyButton.Click
ForceUpdate = True
End Sub
Then it stops calling the ProgressChanged sub (debug shows that it runs the line with ReportProgress in DoWork sub, but it doesn't seem to go into the code)
Anybody who has any idea what could be wrong here?
Last edited: