Unhandled Exception and Control.EndInvoke

M

Michael E. Pouliot

The documentation for Control.BeginInvoke states "Exceptions within the
delegate method are considered untrapped and will be sent to the
application's untrapped exception handler". However, other articles
reference the fact that Control.EndInvoke will marshal an Exception back to
the caller. Upon attempting this, it appears that both are true. The
Exception is marshaled back, but an Unhandled Exception is also raised.
Furthermore, I cannot seem to catch the Unhandled Exception by implementing
handlers for either Application.ThreadException or
AppDomain.UnhandledException.

Optimally, I would want the runtime to not generate an Unhandled Exception,
since it appears to marshal the Exception just fine. Has anyone else dealt
with this issue?

Thanks,
MP
 
M

Michael E. Pouliot

Michael E. Pouliot said:
The documentation for Control.BeginInvoke states "Exceptions within the
delegate method are considered untrapped and will be sent to the
application's untrapped exception handler". However, other articles
reference the fact that Control.EndInvoke will marshal an Exception back
to the caller. Upon attempting this, it appears that both are true. The
Exception is marshaled back, but an Unhandled Exception is also raised.
Furthermore, I cannot seem to catch the Unhandled Exception by
implementing handlers for either Application.ThreadException or
AppDomain.UnhandledException.

Optimally, I would want the runtime to not generate an Unhandled
Exception, since it appears to marshal the Exception just fine. Has
anyone else dealt with this issue?

Thanks,
MP
FYI - I determined why I wasn't able to catch the Unhandled Exception. It
turns out (probably obviously) that Application.ThreadException is specific
to the thread on which the exception is thrown. In my situation, I had
created a secondary thread which was running its own message pump (via
Application.Run()). Once I setup the event handler in that thread, I was
able to catch the Unhandled Exception. The runtime still both marshals the
exception and raises an Unhandled Exception, but at least now I can suppress
the Unhandled Exception dialog box.

MP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top