I have general exception handling in my Winforms app like this:
static void Main()
{
Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new CustomApplicationContext());
Environment.Exit(-1);
}
static void Application_ThreadException(object sender, ThreadExceptionEventArgs e)
{
ShowException(e.Exception);
}
static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
ShowException(e.ExceptionObject as Exception);
Thread.CurrentThread.Suspend();
}
What is the alternative to the Suspend
method and what is the correct to use it in the above scenario?