title: c# Invalid Operation Exception when closing my form
body: <p>I have created a simple form that creates two classes A and B.  Class A kicks off a Thread that fires and event every second.  Class B subscribes to this event and updates a label.  Code looks something like this:</p>
  
  <p>class A...</p>
  
  <pre><code>public delegate void MyEventHandler(string text);
  public event MyEventHandler MyEvent;
  ...
  int i = 0;
  if(MyEvent != null)
    MyEvent(i.ToString());
  i++;
  </code></pre>
  
  <p>class B...</p>
  
  <pre><code>public delegate void MyEventHandler(string text);
  void IncomingEvent(string text)
  {
    if(InvokeRequired)
      Invoke(new MyEventHandler(IncomingEvent), text);
    else
      label.Text = text;
  }
  </code></pre>
  
  <p>This code seems to work just as expected until i try to close the form.  When closing my Invoke line throw an InvalidOperationException.  I assume this is because my form is disposed of prior to my last event going off.  I obviously can catch this exception and tuck it under the rug like it never happened but i'm curious on what the correct way in handling this is.  Thanks in advance for the help.</p>