2008-12-08 Atsushi Enomoto <atsushi@ximian.com>
[mono.git] / mono / tests / cas / threads / timer2.cs
index c66a69f90cbdea9b0368dad4f999a4d4977e5d4e..558527a0da07c7eb4f2be270b1989654f4f0435d 100644 (file)
@@ -1,4 +1,5 @@
 using System;
+using System.Reflection;
 using System.Security;
 using System.Security.Permissions;
 using System.Timers;
@@ -11,12 +12,17 @@ class Program {
                        Console.WriteLine ("{0}: {1}", counter, Environment.StackTrace);
 
                try {
-                       Environment.Exit (1);
+                       Console.WriteLine (Assembly.GetExecutingAssembly ().Evidence.Count);
+                       result = 1;
                }
                catch (SecurityException se) {
                        if (debug)
                                Console.WriteLine ("EXPECTED SecurityException {0}", se);
                }
+               catch (Exception ex) {
+                       Console.WriteLine ("UNEXPECTED {0}", ex);
+                       result = 1;
+               }
 
                if (counter++ > 5) {
                        t.AutoReset = false;
@@ -26,10 +32,11 @@ class Program {
 
        static bool debug;
        static int counter = 0;
+       static int result = 0;
        static Timer t;
 
-       // this Deny will prevent Environment.Exit from working
-       [SecurityPermission (SecurityAction.Deny, UnmanagedCode = true)]
+       // this Deny will prevent the Assembly.Evidence property from working
+       [SecurityPermission (SecurityAction.Deny, ControlEvidence = true)]
        static int Main (string[] args)
        {
                debug = (args.Length > 0);
@@ -50,6 +57,6 @@ class Program {
                t.Enabled = true;
                
                System.Threading.Thread.Sleep (5000);
-               return 0;
+               return result;
        }
 }