Merge pull request #2034 from alexrp/ctx-cleanup
[mono.git] / mono / tests / unhandled-exception-4.cs
1 using System;
2 using System.Diagnostics;
3 using System.Threading;
4 using System.Threading.Tasks;
5
6 class CustomException : Exception
7 {
8 }
9
10 class Driver
11 {
12         /* expected exit code: 0 */
13         static void Main (string[] args)
14         {
15                 ManualResetEvent mre = new ManualResetEvent (false);
16
17                 var t = Task.Factory.StartNew (new Action (() => { try { throw new CustomException (); } finally { mre.Set (); } }));
18
19                 if (!mre.WaitOne (5000))
20                         Environment.Exit (2);
21
22                 try {
23                         t.Wait ();
24                         Environment.Exit (5);
25                 } catch (AggregateException ae) {
26                         if (!(ae.InnerExceptions [0] is CustomException))
27                                 Environment.Exit (4);
28                 } catch (Exception ex) {
29                         Console.WriteLine (ex);
30                         Environment.Exit (3);
31                 }
32
33                 Environment.Exit (0);
34         }
35 }