Merge pull request #5714 from alexischr/update_bockbuild
[mono.git] / mono / tests / threadpool-exceptions4.cs
1 using System;
2 using System.Threading;
3
4 class Test {
5         static object monitor;
6
7         static int Main ()
8         {
9                 monitor = new object ();
10                 AppDomain.CurrentDomain.UnhandledException += OnUnhandledException;
11                 WaitCallback wcb = new WaitCallback ((a) => {
12                         throw new Exception ("From the threadpoool");
13                 });
14                 wcb.BeginInvoke (wcb, OnCBFinished, null);
15                 lock (monitor) {
16                         Monitor.Wait (monitor);
17                 }
18                 Thread.Sleep (1000);
19                 return 1;
20         }
21
22         static void OnCBFinished (object arg)
23         {
24                 throw new Exception ("From OnCBFinished");
25         }
26
27         static void OnUnhandledException (object sender, UnhandledExceptionEventArgs e)
28         {
29                 lock (monitor) {
30                         Monitor.Pulse (monitor);
31                 }
32                 Environment.Exit (0);
33         }
34 }
35