New test.
[mono.git] / mono / tests / cas / threads / delegate2.cs
index 323ec78171849dbbef68db96b133037819f824fa..9b5b16c6aaa0957557f2d791d20bb07c3faeb963 100644 (file)
@@ -1,4 +1,5 @@
 using System;
+using System.Reflection;
 using System.Security;
 using System.Security.Permissions;
 using System.Threading;
@@ -14,25 +15,32 @@ public class Program {
                        if (name == null)
                                name = "[unnamed]";
 
-                       Console.WriteLine ("\tDelegate: {0} (from pool: {1})\n{2}", name, 
+                       Console.WriteLine ("\tDelegate running on thread: {0} (from pool: {1})\n{2}", name, 
                                Thread.CurrentThread.IsThreadPoolThread, 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;
+               }
        }
 
        static bool debug;
+       static int result;
 
-       // 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)]
        public static int Main (string[] args)
        {
+               result = 0;
                debug = (args.Length > 0);
                if (debug) {
                        Thread.CurrentThread.Name = "Main";
@@ -51,6 +59,6 @@ public class Program {
                if (debug)
                        Console.WriteLine ("<Thread.Name: {0}", Thread.CurrentThread.Name);
                
-               return 0;
+               return result;
        }
 }