views:

279

answers:

1

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.

A: 

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.

Drew Marsh
but is this the best-practice for handling these kinds of scenarios?
Firoso
How you communicate the exception totally depends on your applications needs, but yes this is the way you handle these kinds of exceptions in a "global" way for application.
Drew Marsh