title: How can I debug an unhandled exception in code called from a BackgroundWorker?
body: <p>I am running some import code asynchronously from a simple WinForms app using a <code>BackgroundWorker</code> object and its <code>DoAsync()</code> method.  I had a problem where I didn't know that exceptions were being thrown and the thread was prematurely dying.  I eventually discovered this, and now know when an exception is thrown after reading <a href="https://stackoverflow.com/questions/1044460/unhandled-exceptions-in-backgroundworker">Unhandled exceptions in BackgroundWorker</a>.</p>
  
  <p>However, I still have a problem while debugging.  How do I debug this code?  I guess I could run it in a test app that doesn't use a BackgrounWorker, but is there a way to debug this as is?  If I step through the code that actually throws the exception, I just get kicked out the step-through when the exception occurs.  Re-throwing the exception from the <code>RunWorkerCompletedEventHandler</code> naturally doesn't help much either.</p>
  
  <p>Any ideas!?  Thanks in advance!</p>