[sgen] Clear the card table in the finishing pause
[mono.git] / mcs / tests / test-async-19.cs
1 using System;
2 using System.Threading;
3 using System.Threading.Tasks;
4
5 class C
6 {
7         static ManualResetEvent caught = new ManualResetEvent (false);
8
9         static async void Test (ManualResetEvent mre)
10         {
11                 var a = Task.Factory.StartNew (() => {
12                         if (mre.WaitOne (1000))
13                                 throw new ApplicationException ();
14                 });
15
16                 await a.ConfigureAwait (false);
17         }
18
19         public static int Main ()
20         {
21                 ManualResetEvent mre = new ManualResetEvent (false);
22                 Test (mre);
23
24                 var handler = new UnhandledExceptionEventHandler (CurrentDomain_UnhandledException);
25                 AppDomain.CurrentDomain.UnhandledException += handler;
26                 try {
27                         mre.Set ();
28
29                         if (!caught.WaitOne (1000))
30                                 return 1;
31
32                         return 0;
33                 } finally {
34                         AppDomain.CurrentDomain.UnhandledException -= handler;
35                 }
36         }
37
38         static void CurrentDomain_UnhandledException (object sender, UnhandledExceptionEventArgs e)
39         {
40                 if (e.ExceptionObject is ApplicationException)
41                         caught.Set ();
42         }
43 }