I'm implementing a centralized exception handling routine using the
Enterprise Library Exception Management Application Block.
I trap all unhandled exceptions to one place using the following method:
// --- Create an Exception Handler for Thread Exceptions ----------------
Application.Thr eadException += new
ThreadException EventHandler(On ThreadException );
// --- Create an Exception Handler for Unhandled Exceptions -------------
AppDomain currentDomain = AppDomain.Curre ntDomain;
currentDomain.U nhandledExcepti on += new
UnhandledExcept ionEventHandler (OnUnhandledExc eption);
private static void OnThreadExcepti on(object sender,
ThreadException EventArgs t)
//
*************** *************** *************** *************** *************** ***
// Handles Normal Thread Exceptions
//
*************** *************** *************** *************** *************** ***
{
Exceptions.LogA ndReportError(t .Exception);
}
private static void OnUnhandledExce ption(object sender,
UnhandledExcept ionEventArgs args)
//
*************** *************** *************** *************** *************** ***
// Handles All Unhandled Exceptions
//
*************** *************** *************** *************** *************** ***
{
Exceptions.LogA ndReportError(a rgs.ExceptionOb ject as System.Exceptio n);
}
The problem I have is that exceptions that occur on a background thread are
not being picked up. If I do a "throw" on an exception in a background
thread it has no place to go and just disappears as an unhandled exception.
How can I pick up these exceptions without handling them in the background
thread?
Thanks,
Chuck Cobb