[interp] Remove unreachable code (#12411)
[mono-project.git] / mono / tests / unhandled-exception-7.cs
blob87c5fbb8cb17137e5df5aebcfccd7edfe88d11c9
1 using System;
2 using System.Diagnostics;
3 using System.Threading;
4 using System.Threading.Tasks;
5 using System.Runtime.Remoting.Messaging;
7 class CustomException : Exception
11 class CrossDomain : MarshalByRefObject
13 public Action NewDelegateWithTarget ()
15 return new Action (Bar);
18 public Action NewDelegateWithoutTarget ()
20 return () => { throw new CustomException (); };
23 public void Bar ()
25 throw new CustomException ();
29 class Driver
31 /* expected exit code: 255 */
32 static void Main (string[] args)
34 if (Environment.GetEnvironmentVariable ("TEST_UNHANDLED_EXCEPTION_HANDLER") != null)
35 AppDomain.CurrentDomain.UnhandledException += (s, e) => {};
37 ManualResetEvent mre = new ManualResetEvent (false);
39 var ad = AppDomain.CreateDomain ("ad");
41 if (Environment.GetEnvironmentVariable ("TEST_UNHANDLED_EXCEPTION_HANDLER") != null)
42 ad.UnhandledException += (s, e) => {};
44 var cd = (CrossDomain) ad.CreateInstanceAndUnwrap (typeof(CrossDomain).Assembly.FullName, "CrossDomain");
46 var action = cd.NewDelegateWithoutTarget ();
47 var ares = action.BeginInvoke (Callback, null);
49 Thread.Sleep (5000);
51 Environment.Exit (1);
54 static void Callback (IAsyncResult iares)
56 ((Action) ((AsyncResult) iares).AsyncDelegate).EndInvoke (iares);