
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
Getting Exception Information
|
393
Exception event handlers are a great help when used in multithreaded code. In the
1.x versions of the Framework, if an unhandled exception were thrown in a thread
other than the main thread, that thread would abort. However, only the worker
thread, and not the application as a whole, would terminate. But you were not
clearly notified when the CLR aborted this thread, which could cause some interest-
ing debugging problems. In Version 2.0 of the Framework, any unhandled exception
will now propagate and cause the application to terminate. However, when an
exception event handler is used, you can be notified of any unhandled exceptions
that occur in any worker thread and that cause it to abort.
The exception event handler captures unhandled exceptions for only the primary
application domain. Any application domains created from the primary application
domain do not fire this event for unhandled exceptions. These secondary
AppDomains
must be registered with as well for the UnhandledException event individually to
receive their exception events. Note that if the exception is thrown on the main
thread, the system will bring up an error dialog before running the exception event
handler.
See Also
See the “Error Raising and Handling Guidelines” and “UnhandledException- ...