I’ve been struggling with event handling in backgroundworker threads.
All the documentation I’ve come across make me believe that when a DoWork event handler throws an exception that exception should be dealt with in the RunWorkerCompleted handler and that exception will be available in the Error property of the RunWorkerCompletedEventArgs.
This is fine, but during debug time I always see an exception unhandled by user code message. This makes me believe there is a problem with my approach.
What steps should I take to resolve this?
Regards, Jonathan
I’ve seen this behavior before, and I’ve gotten around it by decorating the DoWork handler with the
System.Diagnostics.DebuggerNonUserCodeattribute:Note that you’ll only see this if you’re running in the debugger; even without the attribute, all is as it should be when running from the shell.
I looked this up again, and I still can’t see any good reason why you need to do this. I’m calling it a debugger misfeature.