替代已弃用的线程挂起方法?

时间:2018-09-16 05:55:13

标签: c# winforms

我的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方法的替代方法是什么?在上述情况下使用它的正确方法是什么?

0 个答案:

没有答案