2 using System
.Threading
;
6 static ManualResetEvent mre
= new ManualResetEvent (false);
10 AppDomain
.CurrentDomain
.UnhandledException
+= OnUnhandledException
;
11 WaitCallback wcb
= new WaitCallback ((a
) => {
12 throw new Exception ("From the threadpoool");
14 wcb
.BeginInvoke (wcb
, OnCBFinished
, null);
16 if (!mre
.WaitOne (10000))
20 GC
.WaitForPendingFinalizers ();
22 /* expected exit code: 255 */
27 static void OnUnhandledException (object sender
, UnhandledExceptionEventArgs e
)
29 string str
= e
.ExceptionObject
.ToString ();
30 if (!str
.Contains ("From OnCBFinished")) {
35 if (!e
.IsTerminating
) {
43 static void OnCBFinished (object arg
)
45 throw new Exception ("From OnCBFinished");