2 using System.Threading;
4 public class MultiThreadExceptionTest {
6 public static int result = 0;
8 public static void ThreadStart1 () {
9 Console.WriteLine("{0} started",
10 Thread.CurrentThread.Name);
18 Console.WriteLine ("Count: " + i++);
22 catch (ThreadAbortException e) {
23 Console.WriteLine ("cought exception level 3 ");
25 // Check that the exception is only rethrown in
26 // the appropriate catch clauses
28 // This doesn't work currently, see
29 // http://bugzilla.ximian.com/show_bug.cgi?id=68552
36 throw new DivideByZeroException ();
43 // Check that the exception is properly rethrown
46 } catch (ThreadAbortException e) {
47 Console.WriteLine ("cought exception level 2 " + e.ExceptionState);
48 Console.WriteLine (e);
49 if ((string)e.ExceptionState == "STATETEST")
55 } catch (ThreadAbortException e) {
56 Console.WriteLine ("cought exception level 1 " + e.ExceptionState);
57 Console.WriteLine (e);
58 if (e.ExceptionState == null)
61 } catch (Exception e) {
62 Console.WriteLine ("cought exception level 0")
63 ; Console.WriteLine (e);
64 Console.WriteLine (e.StackTrace);
70 } catch (System.Threading.ThreadStateException e) {
74 Console.WriteLine ("end");
78 static string regress_78024 ()
81 Thread.CurrentThread.Abort ();
82 } catch (Exception e) {
83 return "Got exception: " + e.Message;
89 public static int Main() {
91 // Check aborting the current thread
94 Thread.CurrentThread.Abort ();
103 Thread t1 = new Thread(new ThreadStart
104 (MultiThreadExceptionTest.ThreadStart1));
105 t1.Name = "Thread 1";
112 t1.Abort ("STATETEST");
115 Console.WriteLine ("Result: " + result);
124 } catch (Exception ex) {
129 catch (ThreadAbortException ex) {
130 Thread.ResetAbort ();
138 catch (ThreadAbortException ex) {
139 Thread.ResetAbort ();
145 public static void Run ()
148 Thread.CurrentThread.Abort ();
149 } catch (Exception ex) {
150 throw new Exception ("other");