2 using System.Diagnostics;
3 using System.Threading;
4 using System.Threading.Tasks;
6 class CustomException : Exception
12 static ManualResetEvent mre = new ManualResetEvent (false);
19 throw new CustomException ();
26 /* expected exit code: 255 */
27 static void Main (string[] args)
29 if (Environment.GetEnvironmentVariable ("TEST_UNHANDLED_EXCEPTION_HANDLER") != null)
30 AppDomain.CurrentDomain.UnhandledException += (s, e) => {};
35 GC.WaitForPendingFinalizers ();
37 if (!mre.WaitOne (5000))
40 /* Give a chance to the finalizer thread to finish executing the exception unwinding
41 * after the finally, before we exit with status 0 on the current thread */