[configure] Add new target.
[mono-project.git] / mcs / tests / test-async-19.cs
blob45201aba113ff6fb11c5b8e3cf5fc18f11268c6e
1 using System;
2 using System.Threading;
3 using System.Threading.Tasks;
5 class C
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 ();
14 });
16 await a.ConfigureAwait (false);
19 public static int Main ()
21 ManualResetEvent mre = new ManualResetEvent (false);
22 Test (mre);
24 var handler = new UnhandledExceptionEventHandler (CurrentDomain_UnhandledException);
25 AppDomain.CurrentDomain.UnhandledException += handler;
26 try {
27 mre.Set ();
29 if (!caught.WaitOne (1000))
30 return 1;
32 return 0;
33 } finally {
34 AppDomain.CurrentDomain.UnhandledException -= handler;
38 static void CurrentDomain_UnhandledException (object sender, UnhandledExceptionEventArgs e)
40 if (e.ExceptionObject is ApplicationException)
41 caught.Set ();