merge r67228-r67235, r67237, r67251 and r67256-67259 to trunk (they are
[mono.git] / mono / tests / cas / threads / thread2.cs
1 using System;
2 using System.Security;
3 using System.Security.Permissions;
4 using System.Threading;
5
6 class Program {
7
8         static void ThreadProc ()
9         {
10                 if (debug)
11                         Console.WriteLine (Environment.StackTrace);
12
13                 try {
14                         Environment.Exit (1);
15                 }
16                 catch (SecurityException se) {
17                         if (debug)
18                                 Console.WriteLine ("EXPECTED SecurityException {0}", se);
19                 }
20         }
21
22         static bool debug;
23
24         // this Deny will prevent Environment.Exit from working
25         [SecurityPermission (SecurityAction.Deny, UnmanagedCode = true)]
26         static void Start (Thread t)
27         {
28                 t.Start ();
29         }
30
31         static int Main (string[] args)
32         {
33                 debug = (args.Length > 0);
34                 Thread t = new Thread (new ThreadStart (ThreadProc));
35                 Start (t);
36                 Thread.Sleep (1000);
37                 return 0;
38         }
39 }