X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mono%2Ftests%2Funhandled-exception-6.cs;h=7ed54d333006cfbf8d83185ffc7d5b9d720d9369;hb=HEAD;hp=b9c25496c5a189617df4cadcc37732491dd896b7;hpb=ccdf8c3274d1793ffeddedfd784d49707feea62a;p=mono.git diff --git a/mono/tests/unhandled-exception-6.cs b/mono/tests/unhandled-exception-6.cs index b9c25496c5a..7ed54d33300 100644 --- a/mono/tests/unhandled-exception-6.cs +++ b/mono/tests/unhandled-exception-6.cs @@ -2,40 +2,35 @@ using System; 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); } }