Hi, Whats the best way to handle updating the UI lots of times from a worker thread. Depending on speed the UI may need updating 3/4 times in a second. Say if the overall task takes 1 minute to complete, we could have over 100 updates in that given time.

My problem is it feels like i am creating a worker thread just to constantly jump back to the UI thread.

do you think the SynchronizationContext class would be better suited then what i am doing below.

vb Code:
  1. Public Class MainForm
  2.  
  3.     Private Event SomeThingChnaged As EventHandler(Of SomeThingChnagedEventArghs)
  4.  
  5.     Private Sub StartButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles StartButton.Click
  6.         Dim t As New System.Threading.Thread(AddressOf DoWork)
  7.         t.Start()
  8.     End Sub
  9.  
  10.     Private Sub DoWork()
  11.         ' Do work
  12.         RaiseEvent SomeThingChnaged(Me, New SomeThingChnagedEventArghs("Data"))
  13.         'do work
  14.         RaiseEvent SomeThingChnaged(Me, New SomeThingChnagedEventArghs("Data"))
  15.         ' and so on
  16.     End Sub
  17.  
  18.     Private Sub UpdateInterface(ByVal sender As Object, ByVal e As EventArgs) Handles Me.SomeThingChnaged
  19.         If Me.StatusTextBox.InvokeRequired Then
  20.             Me.StatusTextBox.Invoke(New Action(Of Object, EventArgs)(AddressOf UpdateInterface), sender, e)
  21.         Else
  22.             Dim value As String = DirectCast(sender, SomeThingChnagedEventArghs).Value
  23.             Me.StatusTextBox.AppendText(value & vbNewLine)
  24.         End If
  25.     End Sub
  26.  
  27. End Class