我的Winforms应用程序中具有如下常规异常处理:
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();
}
Suspend
方法的替代方法是什么?在上述情况下使用它的正确方法是什么?