在UI线程中

在APP.XAML中定义 DispatcherUnhandledException事件

在工作线程中

 PageMain.GetInstance().Dispatcher.Invoke((MethodInvoker)delegate  {

throw ex;
}

任何当前Dispatcher线程(即UI线程)的未处理异常都可以选择处理或者不处理(通过DispatcherUnhandledExceptionEventArgs.IsHandled属性),选择处理的话未处理异常就不会崩溃整个WPF应用程序了。

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-12-14
  • 2022-12-23
  • 2021-07-22
  • 2022-03-05
  • 2021-11-15
猜你喜欢
  • 2022-12-23
  • 2021-07-17
  • 2021-06-18
  • 2021-06-20
  • 2022-02-06
  • 2021-07-25
相关资源
相似解决方案