Properly handling exceptions thrown in a thread or via the WPF dispatcher
When a thread throws an exception that is unhandled, it terminates. What is the proper way to handle exceptions thrown on threads and how to propogate relevant exception data to other parts of the code that would need to subscribe to notifications? Is 开发者_StackOverflow中文版there an INotifyThreadPoorlyDesigned interface that I missed somewhere?
Same applies for how to handle stuff dispatched to the WPF UI.
To handle work that throws an exception on a dispatcher thread, simply hook the Application::DispatcherUnhandledException
event. To handle non-dispathcer thread exceptions, you just need to hook the standard AppDomain::UnhandledException
event.
精彩评论