using System.Diagnostics;
using System.Threading;
using System.Threading.Tasks;
+using System.Runtime.Remoting.Messaging;
class CustomException : Exception
{
}
-class CustomException2 : Exception
-{
-}
-
class Driver
{
- /* expected exit code: 0 */
+ /* expected exit code: 255 */
static void Main (string[] args)
{
- ManualResetEvent mre = new ManualResetEvent (false);
- ManualResetEvent mre2 = new ManualResetEvent (false);
+ if (Environment.GetEnvironmentVariable ("TEST_UNHANDLED_EXCEPTION_HANDLER") != null)
+ AppDomain.CurrentDomain.UnhandledException += (s, e) => {};
+
+ var action = new Action (Delegate);
+ var ares = action.BeginInvoke (Callback, null);
- var a = new Action (() => { try { throw new CustomException (); } finally { mre.Set (); } });
- var ares = a.BeginInvoke (_ => { mre2.Set (); throw new CustomException2 (); }, null);
+ Thread.Sleep (5000);
- if (!mre.WaitOne (5000))
- Environment.Exit (2);
- if (!mre2.WaitOne (5000))
- Environment.Exit (22);
+ Environment.Exit (1);
+ }
- try {
- a.EndInvoke (ares);
- Environment.Exit (4);
- } catch (CustomException) {
- } catch (Exception ex) {
- Console.WriteLine (ex);
- Environment.Exit (3);
- }
+ static void Delegate ()
+ {
+ throw new CustomException ();
+ }
- Environment.Exit (0);
+ static void Callback (IAsyncResult iares)
+ {
+ ((Action) ((AsyncResult) iares).AsyncDelegate).EndInvoke (iares);
}
}