2 using System.Threading;
5 static int return_value = 2;
8 AppDomain.CurrentDomain.UnhandledException += OnUnhandledException;
9 WaitCallback wcb = new WaitCallback ((a) => {
10 Thread.CurrentThread.Abort();
12 wcb.BeginInvoke (wcb, OnCBFinished, null);
17 static void OnUnhandledException (object sender, UnhandledExceptionEventArgs e)
19 string str = e.ExceptionObject.ToString ();
20 if (str.IndexOf ("From the threadpool") != -1)
22 Environment.Exit (return_value);
25 static void OnCBFinished (object arg)
28 throw new Exception ("From OnCBFinished");