How can I debug an unhandled exception in code called from a BackgroundWorker?
        Posted  
        
            by SkippyFire
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by SkippyFire
        
        
        
        Published on 2010-03-12T20:48:12Z
        Indexed on 
            2010/03/12
            21:07 UTC
        
        
        Read the original article
        Hit count: 328
        
I am running some import code asynchronously from a simple WinForms app using a BackgroundWorker object and its DoAsync() 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 Unhandled exceptions in BackgroundWorker.
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 RunWorkerCompletedEventHandler naturally doesn't help much either.
Any ideas!? Thanks in advance!
© Stack Overflow or respective owner