Please see my question on Stackoverflow here:
As stated in the above link my objective is to handle all exceptions on all threads in a global exception handler. After posting on SO I found this document which is very helpful:
http://msdn.microsoft.com/en-us/library/dd997415(v=vs.100).aspx
I tried to modify the code in the link above to fit my purpose. I added a continuation which causes it to crash with the exception noted in the code below. Can you please assist me in accomplishing the objective above?
public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); Loaded += new RoutedEventHandler(MainWindow_Loaded); } void MainWindow_Loaded(object sender, RoutedEventArgs e) { Task task = Task.Factory.StartNew(() => { Task t2 = Task.Factory.StartNew(() => { throw new Exception("boo"); // The current SynchronizationContext may not be used as a TaskScheduler. }, CancellationToken.None,TaskCreationOptions.None,TaskScheduler.FromCurrentSynchronizationContext()) .ContinueWith(t => { int z = 1; }, CancellationToken.None,TaskContinuationOptions.NotOnFaulted,TaskScheduler.FromCurrentSynchronizationContext()); t2.Wait(); }, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.FromCurrentSynchronizationContext()); try { task.Wait(); } catch (Exception ex) { // The app exception handler should catch this: throw new Exception("Task", ex); } } }