Firoso
Firoso

Reputation: 6675

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 there an INotifyThreadPoorlyDesigned interface that I missed somewhere?

Same applies for how to handle stuff dispatched to the WPF UI.

Upvotes: 0

Views: 1146

Answers (1)

Drew Marsh
Drew Marsh

Reputation: 33379

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.

Upvotes: 1

Related Questions