SilverShotBee SilverShotBee - 1 year ago 77 Question

Vb.Net Background Worker Updating UI Not Working

I have a background worker that is supposed to be updating a

with some status messages. However, the updating is not happening, but no errors are being thrown. Here's the code I am using:

Private Sub BackgroundWorker3_DoWork(sender As Object, e As DoWorkEventArgs) Handles BackgroundWorker3.DoWork
BackgroundWorker3.WorkerReportsProgress = True
Dim Counter As Integer = 0

Do Until BW1Running = False
Counter = Counter + 1
If Counter >= 100 Then
e.Result = False
End If


If BW1Running = False Then
Counter = 100
End If
End Sub

Private Sub BackgroundWorker3_ProgressChanged(sender As Object, e As ProgressChangedEventArgs) Handles BackgroundWorker3.ProgressChanged

Me.ToolStripStatusLabel1.Text = e.ProgressPercentage.ToString

End Sub

Nothing happens when the
is fired. I've debugged it and it'll print a line to the output window, but it will not update that label. Any ideas on what I'm missing?

Answer Source

You're calling:


instead of just:


Your BackgroundWorker3_ProgressChanged method is subscribed to the ProgressChanged event of the BackgroundWorker located in the current form, not in the Incident_Form form.

Remove Incident_Form from the beginning of the BackgroundWorker3.ReportProgress() calls and you should be good to go.