Lazily nit mono_class_setup_supertypes correctly.
[mono-project.git] / mcs / tests / test-async-19.cs
blob28a8b68fd97123fa9b12639e2f82a856e333c0d3
1 // Compiler options: -langversion:future
3 using System;
4 using System.Threading;
5 using System.Threading.Tasks;
7 class C
9 static ManualResetEvent caught = new ManualResetEvent (false);
11 static async void Test (ManualResetEvent mre)
13 var a = Task.Factory.StartNew (() => {
14 if (mre.WaitOne (1000))
15 throw new ApplicationException ();
16 });
18 await a;
21 public static int Main ()
23 ManualResetEvent mre = new ManualResetEvent (false);
24 Test (mre);
26 var handler = new UnhandledExceptionEventHandler (CurrentDomain_UnhandledException);
27 AppDomain.CurrentDomain.UnhandledException += handler;
28 try {
29 mre.Set ();
31 if (!caught.WaitOne (1000))
32 return 1;
34 return 0;
35 } finally {
36 AppDomain.CurrentDomain.UnhandledException -= handler;
40 static void CurrentDomain_UnhandledException (object sender, UnhandledExceptionEventArgs e)
42 if (e.ExceptionObject is ApplicationException)
43 caught.Set ();