May 10, 2012 at 2:41 PM
Edited May 10, 2012 at 2:49 PM
|
Hello,
I am trying to log unhandled exceptions in my WPF application. I would like to achieve following three functions when there is an unhandled exception-
1) Log the exception using Log4Net
2) Show error message
3) Shut down the application when user clicks ok on the message box.
Here is the code I am using (without the logging piece). Is this the right way to handle the messagebox? What if I want to display WPF toolkit message box using the couroutine? Can some one please point me in the right direction to accomplish above mentioned
tasks?
protected override void OnUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
{
base.OnUnhandledException(sender, e);
Execute.OnUIThread(() =>
{
MessageBox.Show(e.Exception.Message, "Application Exception", MessageBoxButton.OK);
});
Application.Shutdown();
}
Thanks
Apurva
|