Merge pull request #5714 from alexischr/update_bockbuild
[mono.git] / mono / tests / unhandled-exception-1.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: 1 */
13         static void Main (string[] args)
14         {
15                 if (Environment.GetEnvironmentVariable ("TEST_UNHANDLED_EXCEPTION_HANDLER") != null)
16                         AppDomain.CurrentDomain.UnhandledException += (s, e) => {};
17
18                 ManualResetEvent mre = new ManualResetEvent (false);
19
20                 var t = new Thread (new ThreadStart (() => { try { throw new CustomException (); } finally { mre.Set (); } }));
21                 t.Start ();
22
23                 if (!mre.WaitOne (5000))
24                         Environment.Exit (2);
25
26                 /* Give a chance to the thread to finish executing the exception unwinding
27                  * after the finally, before we exit with status 0 on the current thread */
28                 Thread.Sleep (1000);
29
30                 Environment.Exit (0);
31         }
32 }