Merge pull request #2274 from esdrubal/udpclientreceive
[mono.git] / mono / tests / unhandled-exception-7.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 CrossDomain : MarshalByRefObject
15 {
16         public Action NewDelegateWithTarget ()
17         {
18                 return new Action (Bar);
19         }
20
21         public Action NewDelegateWithoutTarget ()
22         {
23                 return () => { throw new CustomException (); };
24         }
25
26         public void Bar ()
27         {
28                 throw new CustomException ();
29         }
30 }
31
32 class Driver
33 {
34         /* expected exit code: 0 */
35         static void Main (string[] args)
36         {
37                 ManualResetEvent mre = new ManualResetEvent (false);
38
39                 var cd = (CrossDomain) AppDomain.CreateDomain ("ad").CreateInstanceAndUnwrap (typeof(CrossDomain).Assembly.FullName, "CrossDomain");
40
41                 var a = cd.NewDelegateWithoutTarget ();
42                 var ares = a.BeginInvoke (delegate { throw new CustomException2 (); }, null);
43
44                 try {
45                         a.EndInvoke (ares);
46                         Environment.Exit (4);
47                 } catch (CustomException) {
48                 } catch (Exception ex) {
49                         Console.WriteLine (ex);
50                         Environment.Exit (3);
51                 }
52
53                 Environment.Exit (0);
54         }
55 }