C
Chuck Cobb
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.ThreadException += new
ThreadExceptionEventHandler(OnThreadException);
// --- Create an Exception Handler for Unhandled Exceptions -------------
AppDomain currentDomain = AppDomain.CurrentDomain;
currentDomain.UnhandledException += new
UnhandledExceptionEventHandler(OnUnhandledException);
private static void OnThreadException(object sender,
ThreadExceptionEventArgs t)
//
******************************************************************************
// Handles Normal Thread Exceptions
//
******************************************************************************
{
Exceptions.LogAndReportError(t.Exception);
}
private static void OnUnhandledException(object sender,
UnhandledExceptionEventArgs args)
//
******************************************************************************
// Handles All Unhandled Exceptions
//
******************************************************************************
{
Exceptions.LogAndReportError(args.ExceptionObject as System.Exception);
}
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
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.ThreadException += new
ThreadExceptionEventHandler(OnThreadException);
// --- Create an Exception Handler for Unhandled Exceptions -------------
AppDomain currentDomain = AppDomain.CurrentDomain;
currentDomain.UnhandledException += new
UnhandledExceptionEventHandler(OnUnhandledException);
private static void OnThreadException(object sender,
ThreadExceptionEventArgs t)
//
******************************************************************************
// Handles Normal Thread Exceptions
//
******************************************************************************
{
Exceptions.LogAndReportError(t.Exception);
}
private static void OnUnhandledException(object sender,
UnhandledExceptionEventArgs args)
//
******************************************************************************
// Handles All Unhandled Exceptions
//
******************************************************************************
{
Exceptions.LogAndReportError(args.ExceptionObject as System.Exception);
}
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