2 using System
.Threading
;
4 public class MultiThreadExceptionTest
{
6 public static int result
= 0;
7 public static object started
= new object ();
9 public static void ThreadStart1 () {
10 Console
.WriteLine("{0} started",
11 Thread
.CurrentThread
.Name
);
17 Monitor
.Pulse (started
);
22 Console
.WriteLine ("Count: " + i
++);
26 catch (ThreadAbortException e
) {
27 Console
.WriteLine ("cought exception level 3 ");
29 // Check that the exception is only rethrown in
30 // the appropriate catch clauses
32 // This doesn't work currently, see
33 // http://bugzilla.ximian.com/show_bug.cgi?id=68552
40 throw new DivideByZeroException ();
47 // Check that the exception is properly rethrown
50 } catch (ThreadAbortException e
) {
51 Console
.WriteLine ("cought exception level 2 " + e
.ExceptionState
);
52 Console
.WriteLine (e
);
53 if ((string)e
.ExceptionState
== "STATETEST")
59 } catch (ThreadAbortException e
) {
60 Console
.WriteLine ("cought exception level 1 " + e
.ExceptionState
);
61 Console
.WriteLine (e
);
62 if (e
.ExceptionState
== null)
65 } catch (Exception e
) {
66 Console
.WriteLine ("cought exception level 0")
67 ; Console
.WriteLine (e
);
68 Console
.WriteLine (e
.StackTrace
);
74 } catch (System
.Threading
.ThreadStateException e
) {
78 Console
.WriteLine ("end");
82 static string regress_78024 ()
85 Thread
.CurrentThread
.Abort ();
86 } catch (Exception e
) {
87 return "Got exception: " + e
.Message
;
93 public static int Main() {
94 // Check aborting the current thread
97 Thread
.CurrentThread
.Abort ();
101 Thread
.ResetAbort ();
109 t1
= new Thread(new ThreadStart
110 (MultiThreadExceptionTest
.ThreadStart1
));
111 t1
.Name
= "Thread 1";
117 Monitor
.Wait (started
);
122 t1
.Abort ("STATETEST");
127 Console
.WriteLine ("Result: " + result
);
135 } catch (Exception ex
) {
140 catch (ThreadAbortException ex
) {
141 Thread
.ResetAbort ();
149 catch (ThreadAbortException ex
) {
150 Thread
.ResetAbort ();
156 public static void Run ()
159 Thread
.CurrentThread
.Abort ();
160 } catch (Exception ex
) {
161 throw new Exception ("other");