title: Updating UI from events using asyc await
body: <p>I am trying to understand how to update a UI from an event while using async/await pattern.
  Below is the test code I am using on a WinForm app. I am not even sure this is the right way to go about it.  What is necessary to allow the pwe_StatusUpdate method to update the UI?  The cross-thread operation error is thrown there. </p>
  
  <p>Thanks for reading.</p>
  
  <pre><code> // calling code
      ProcessWithEvents pwe = new ProcessWithEvents();
      pwe.StatusUpdate += pwe_StatusUpdate;
      await pwe.Run();
  
  
  
   void pwe_StatusUpdate(string updateMsg)
      {
        // Error Here: Cross-thread operation not valid: Control '_listBox_Output' accessed from a thread other than the thread it was created on.
        _listBox_Output.Items.Add(updateMsg);
      }
  </code></pre>
  
  <p>-</p>
  
  <pre><code>// Class with long running process and event    
  public delegate void StatusUpdateHandler(string updateMsg);
  
   public class ProcessWithEvents
    {
      public event StatusUpdateHandler StatusUpdate;
  
      public async Task Run()
      {
          await Task.Run(() =&gt;
          {
              for (int i = 0; i &lt; 10; i++)
                  {
  
                      RaiseUpdateEvent(String.Format("Update {0}", i));
  
                      Thread.Sleep(500);
                  }
              });
  
          }
  
          private void RaiseUpdateEvent(string msg)
          {
          if (StatusUpdate != null)
              StatusUpdate(msg);
          }
     }
  </code></pre>
  
  <p>-</p>