2 using System.Threading;
6 static int return_value = 2;
10 monitor = new object ();
11 AppDomain.CurrentDomain.UnhandledException += OnUnhandledException;
12 WaitCallback wcb = new WaitCallback ((a) => {
13 throw new Exception ("From the threadpoool");
15 wcb.BeginInvoke (wcb, OnCBFinished, null);
17 Monitor.Wait (monitor);
23 static void OnUnhandledException (object sender, UnhandledExceptionEventArgs e)
25 string str = e.ExceptionObject.ToString ();
26 if (str.IndexOf ("From the threadpool") != -1)
29 Monitor.Pulse (monitor);
31 Environment.Exit (return_value);
34 static void OnCBFinished (object arg)
37 throw new Exception ("From OnCBFinished");