b9c25496c5a189617df4cadcc37732491dd896b7
[mono.git] / mono / tests / unhandled-exception-6.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 CustomException2 : Exception
11 {
12 }
13
14 class Driver
15 {
16         /* expected exit code: 0 */
17         static void Main (string[] args)
18         {
19                 ManualResetEvent mre = new ManualResetEvent (false);
20                 ManualResetEvent mre2 = new ManualResetEvent (false);
21
22                 var a = new Action (() => { try { throw new CustomException (); } finally { mre.Set (); } });
23                 var ares = a.BeginInvoke (_ => { mre2.Set (); throw new CustomException2 (); }, null);
24
25                 if (!mre.WaitOne (5000))
26                         Environment.Exit (2);
27                 if (!mre2.WaitOne (5000))
28                         Environment.Exit (22);
29
30                 try {
31                         a.EndInvoke (ares);
32                         Environment.Exit (4);
33                 } catch (CustomException) {
34                 } catch (Exception ex) {
35                         Console.WriteLine (ex);
36                         Environment.Exit (3);
37                 }
38
39                 Environment.Exit (0);
40         }
41 }