正确处理线程中抛出的异常或通过WPF调度程序

时间:2009-11-09 19:05:47

标签: .net wpf exception-handling multithreading

当一个线程抛出一个未处理的异常时,它会终止。处理线程上抛出异常的正确方法是什么,以及如何将相关异常数据传播到需要订阅通知的代码的其他部分?是否有我错过的INotifyThreadPoorlyDesigned界面?

同样适用于如何处理分派到WPF UI的内容。

1 个答案:

答案 0 :(得分:1)

要处理在调度程序线程上抛出异常的工作,只需挂钩the Application::DispatcherUnhandledException event即可。要处理非dispathcer线程异常,您只需要挂钩the standard AppDomain::UnhandledException event