title: Raising events asynchronously
body: <p>I'm looking into options for doing asynchronous event dispatching in a component that has many subscribers to its events.  In perusing the options, I ran across this example:</p>
  
  <pre><code>public event ValueChangedEvent ValueChanged;
  public void FireEventAsync(EventArgs e)
  {
      Delegate[] delegates = ValueChanged.GetInvocationList();
      foreach (Delegate d in delegates)
      {
          ValueChangedEvent ev = (ValueChangedEvent)d;
          ev.BeginInvoke(e, null, null);
      }
  }
  </code></pre>
  
  <p>Beyond the older syntax (the sample was from .NET 1.1), it looks to me like this is a serious resource leak.  There's no completion method, no polling for completion, or any other way that <code>EndInvoke</code> will be called.</p>
  
  <p>My understanding is that every <code>BeginInvoke</code> <em>must have</em> a corresponding <code>EndInvoke</code>. Otherwise there are pending <code>AsyncResult</code> object instances floating around, along with (potentially) exceptions that were raised during the asynchronous events.</p>
  
  <p>I realize that it's easy enough to change that by supplying a callback and doing an <code>EndInvoke</code>, but if I don't need to . . .</p>
  
  <p>Handling the asynchronous exeptions is another matter entirely, and, combined with the need to synchronize with the UI thread (i.e. <code>InvokeRequired</code>, etc.) could very well tank the whole idea of doing these asynchronous notifications.</p>
  
  <p>So, two questions:</p>
  
  <ol>
  <li>Am I correct in believing that every <code>BeginInvoke</code> requires a corresponding <code>EndInvoke</code>?</li>
  <li>Beyond what I've noted above, are there other pitfalls to doing asynchronous event notifications in Windows Forms applications?</li>
  </ol>