2 using System.Threading;
3 using System.Threading.Tasks;
7 static ManualResetEvent caught = new ManualResetEvent (false);
9 static async void Test (ManualResetEvent mre)
11 var a = Task.Factory.StartNew (() => {
12 if (mre.WaitOne (1000))
13 throw new ApplicationException ();
16 await a.ConfigureAwait (false);
19 public static int Main ()
21 ManualResetEvent mre = new ManualResetEvent (false);
24 var handler = new UnhandledExceptionEventHandler (CurrentDomain_UnhandledException);
25 AppDomain.CurrentDomain.UnhandledException += handler;
29 if (!caught.WaitOne (1000))
34 AppDomain.CurrentDomain.UnhandledException -= handler;
38 static void CurrentDomain_UnhandledException (object sender, UnhandledExceptionEventArgs e)
40 if (e.ExceptionObject is ApplicationException)