+
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