2 using System
.Threading
;
6 static int return_value
= 2;
9 monitor
= new object ();
10 AppDomain
.CurrentDomain
.UnhandledException
+= OnUnhandledException
;
11 WaitCallback wcb
= new WaitCallback ((a
) => {
12 Thread
.CurrentThread
.Abort();
14 wcb
.BeginInvoke (wcb
, OnCBFinished
, null);
16 Monitor
.Wait (monitor
);
22 static void OnUnhandledException (object sender
, UnhandledExceptionEventArgs e
)
24 string str
= e
.ExceptionObject
.ToString ();
25 if (str
.IndexOf ("From the threadpool") != -1)
28 Monitor
.Pulse (monitor
);
30 Environment
.Exit (return_value
);
33 static void OnCBFinished (object arg
)
36 throw new Exception ("From OnCBFinished");