WPF DispatcherUnhandledException 异常捕获最后的大门

这里在界面按钮事件下除 0 测试,感觉软件还是退出了?

/// <summary>
/// App.xaml 的交互逻辑
/// </summary>
public partial class App : Application
{
    protected override void OnStartup(StartupEventArgs e)
    {
        base.OnStartup(e);
        DispatcherUnhandledException += App_DispatcherUnhandledException;
    }

    private void App_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
    {
        //throw new NotImplementedException();
        MessageBox.Show(e.Exception.Message + "---" + e.ToString());
    }
}
posted @ 2023-01-30 22:28  double64  阅读(208)  评论(0)    收藏  举报