New test.
[mono.git] / mono / tests / cas / threads / thread1.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 int Main (string[] args)
27         {
28                 debug = (args.Length > 0);
29                 Thread t = new Thread (new ThreadStart (ThreadProc));
30                 t.Start ();
31                 Thread.Sleep (1000);
32                 return 0;
33         }
34 }