Winform Global Exception Handling Pattern Help
Palmer Fred <[email protected]>
| Newsgroups | gmane.comp.windows.devel.dotnet.winforms |
|---|---|
| Message-ID | <[email protected]> |
Hi all,
I'm attempting to establish a pattern global exception catching for a
suite of applications written in .NET 1.1. Here's what I have so far:
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
private static void Main()
{
try
{
// Add the event handler for handling UI
thread exceptions
Application.ThreadException +=
new
ThreadExceptionEventHandler(Application_ThreadException);
// Add the event handler for handling
non-UI thread exceptions
AppDomain.CurrentDomain.UnhandledException +=
new
UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
Application.Run(new
GlobalExceptionPatternTestForm());
}
catch(Exception)
{
// Log/Handle exception
}
}
private static void
CurrentDomain_UnhandledException(object sender,
UnhandledExceptionEventArgs e)
{
// Log/Handle exception
}
private static void Application_ThreadException(object
sender, ThreadExceptionEventArgs e)
{
// Log/Handle exception
}
Thoughts?
Thanks,
Fred