Merge pull request #5714 from alexischr/update_bockbuild
[mono.git] / mono / tests / unhandled-exception-8.cs
index d02896bf028dc39876f07f10adfae201edfc0444..7b4de0e97bfd93b6c1639faade36627de71fb9e7 100644 (file)
@@ -1,55 +1,24 @@
+
 using System;
-using System.Diagnostics;
 using System.Threading;
-using System.Threading.Tasks;
 
 class CustomException : Exception
 {
 }
 
-class CustomException2 : Exception
-{
-}
-
-class CrossDomain : MarshalByRefObject
-{
-       public Action NewDelegateWithTarget ()
-       {
-               return new Action (Bar);
-       }
-
-       public Action NewDelegateWithoutTarget ()
-       {
-               return () => { throw new CustomException (); };
-       }
-
-       public void Bar ()
-       {
-               throw new CustomException ();
-       }
-}
-
 class Driver
 {
-       /* expected exit code: 3 */
-       static void Main (string[] args)
+       /* expected exit code: 255 */
+       public static void Main ()
        {
-               ManualResetEvent mre = new ManualResetEvent (false);
+               if (Environment.GetEnvironmentVariable ("TEST_UNHANDLED_EXCEPTION_HANDLER") != null)
+                       AppDomain.CurrentDomain.UnhandledException += (s, e) => {};
 
-               var cd = (CrossDomain) AppDomain.CreateDomain ("ad").CreateInstanceAndUnwrap (typeof(CrossDomain).Assembly.FullName, "CrossDomain");
+               ManualResetEvent mre = new ManualResetEvent(false);
 
-               var a = cd.NewDelegateWithTarget ();
-               var ares = a.BeginInvoke (delegate { throw new CustomException2 (); }, null);
+               ThreadPool.RegisterWaitForSingleObject (mre, (state, timedOut) => { throw new CustomException (); }, null, -1, true);
+               mre.Set();
 
-               try {
-                       a.EndInvoke (ares);
-                       Environment.Exit (4);
-               } catch (CustomException) {
-               } catch (Exception ex) {
-                       Console.WriteLine (ex);
-                       Environment.Exit (3);
-               }
-
-               Environment.Exit (0);
+               Thread.Sleep (5000);
        }
-}
+}
\ No newline at end of file