Quote Originally Posted by CVMichael View Post
I can't figure out how to send events from a worker thread to the UI thread.
That's because there is no such thing. Events are defined like so:
csharp Code:
  1. public event EventHandler SomethingHappended;
  2.  
  3. protected void OnSomethingHappened(EventArgs e)
  4. {
  5.     SomethingHappened?.Invoke(this, e);
  6. }
The OnX method is where the X event is actually raised. When you want to raise that event, you call that method:
csharp Code:
  1. // Do something here.
  2.  
  3. // Raise the event.
  4. OnSomethingHappened(EventArgs.Empty);
In code that can or will execute on a secondary thread, you can marshal a method call to the UI thread to execute code on the UI thread. That method can do whatever you want. It's just a method. If you want to raise your event in that method, do so, just as I showed above:
csharp Code:
  1. private void RaiseSomethingHappened()
  2. {
  3.     OnSomethingHappened(EventArgs.Empty);
  4. }
and:
csharp Code:
  1. Invoke(RaiseSomethingHappened);
Alternatively, you could use a lambda to call the method that raises the event directly:
csharp Code:
  1. Invoke(() => OnSomethingHappened(EventArgs.Empty));
In summary, you "send" a method call to the UI thread, just as you always do, then raise the event in that method, just as you always do.