title: Why does the inner exception reach the ThreadException handler and not the actual thrown exception?
body: <p>I'm seeing some wierd behaviour when throwing exceptions and catching them in the <code>Application.ThreadException</code> event handler.</p>
  
  <p>Basically whats happening in the sample below is that an exception is thrown in the <code>DoWork</code> event handler of a <code>BackgroundWorker</code>. The <code>RunWorkerCompleted</code> event handler rethrows a new exception with the original as the inner exception.</p>
  
  <p>Why does the inner exception show up in the <code>ThreadException</code> event handler and not the acutal exception being thrown? If I do not provide an inner exception in the <code>RunWorkerCompleted</code> event handler, the correct exception will show up.</p>
  
  <pre><code>using System;
  using System.Windows.Forms;
  using System.ComponentModel;
  
  namespace WierdExceptionApp
  {
      class WierdExceptionForm : Form
      {
          BackgroundWorker worker = new BackgroundWorker();
  
          public WierdExceptionForm()
          {
              worker.DoWork += new DoWorkEventHandler(worker_DoWork);
              worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(worker_RunWorkerCompleted);
              worker.RunWorkerAsync();
          }
  
          void worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
          {
              if (e.Error != null)
              {
                  throw new Exception("worker_RunWorkerCompleted", e.Error);
              }
          }
  
          void worker_DoWork(object sender, DoWorkEventArgs e)
          {
              throw new Exception("worker_DoWork");
          }
  
          [STAThread]
          static void Main()
          {
              Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
              Application.Run(new WierdExceptionForm());
          }
  
          static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
          {
              MessageBox.Show(e.Exception.Message);
          }
     }
  }
  </code></pre>