Merge branch 'master' of github.com:mono/mono
[mono.git] / mono / tests / threadpool-exceptions5.cs
1 using System;
2 using System.Threading;
3
4 class Test {
5         static int return_value = 2;
6         static int Main ()
7         {
8                 AppDomain.CurrentDomain.UnhandledException += OnUnhandledException;
9                 WaitCallback wcb = new WaitCallback ((a) => {
10                         Thread.CurrentThread.Abort();
11                 });
12                 wcb.BeginInvoke (wcb, OnCBFinished, null);
13                 Thread.Sleep (1000);
14                 return 1;
15         }
16
17         static void OnUnhandledException (object sender, UnhandledExceptionEventArgs e)
18         {
19                 string str = e.ExceptionObject.ToString ();
20                 if (str.IndexOf ("From the threadpool") != -1)
21                         return_value = 3;
22                 Environment.Exit (return_value);
23         }
24
25         static void OnCBFinished (object arg)
26         {
27                 return_value = 0;
28                 throw new Exception ("From OnCBFinished");
29         }
30 }
31