I have a WPF application where I make a long WCF call using System.Threading.Tasks. I will catch the unhandled exceptions by adding a handler to Application.Current.DispatcherUnhandledException.
I create a task where the ContinueWith function is executed in the user interface thread using the following code:
var task = new Task<T>(func).ContinueWith(t => { if (t.IsFaulted) { throw t.Exception.GetBaseException(); } else {
When an exception occurs in a task, I would like to rebuild the exception so that the DispatcherUnhandledException handler can handle this. But when I reduce the exception as shown above, it causes my application to crash and the DispatcherUnhandledException is not raised.
How to redraw an exception in a user interface thread to call a DispatcherUnhandledException?
When I used BackgroundWorker, the repeated exception did just that. Basically, I want to replace BackgroundWorker with Task, since Task has some really nice features that I would like to use.
source share