Merge pull request #5382 from kumpera/pedump_fix
[mono.git] / mono / tests / abort-cctor-2.cs
1 using System;
2 using System.Threading;
3
4 public class Critical {
5         static Critical ()
6         {
7                 Program.mre1.Set ();
8                 Program.mre2.WaitOne ();
9                 try {
10                         throw new Exception ();
11                 } catch (Exception) {
12                         Console.WriteLine ("Catched exception in cctor");
13                         Program.catched_exception = true;
14                 }
15         }
16 }
17
18
19 public class Program {
20         public static ManualResetEvent mre1 = new ManualResetEvent (false);
21         public static ManualResetEvent mre2 = new ManualResetEvent (false);
22
23         public static bool catched_exception, catched_abort;
24
25         public static int Main (string[] args)
26         {
27                 Thread thread = new Thread (DoStuff);
28                 thread.Start ();
29
30                 mre1.WaitOne ();
31                 thread.Abort ();
32                 mre2.Set ();
33
34                 thread.Join ();
35
36                 if (!catched_exception)
37                         Environment.Exit (1);
38                 if (!catched_abort)
39                         Environment.Exit (2);
40
41                 Console.WriteLine ("done, all things good");
42                 return 0;
43         }
44
45         public static void DoStuff ()
46         {
47                 try {
48                         new Critical ();
49                 } catch (ThreadAbortException) {
50                         Console.WriteLine ("Catched thread abort");
51                         Program.catched_abort = true;
52                 }
53         }
54 }