[WinForms] Fix #18506 ActiveTracker, do not propagate message to control when it...
[mono-project.git] / mono / tests / unhandled-exception-2.cs
blobcb05c269fd82c0f31e220092d8744d70dc519868
1 using System;
2 using System.Diagnostics;
3 using System.Threading;
4 using System.Threading.Tasks;
6 class CustomException : Exception
10 class Driver
12 /* expected exit code: 255 */
13 static void Main (string[] args)
15 if (Environment.GetEnvironmentVariable ("TEST_UNHANDLED_EXCEPTION_HANDLER") != null)
16 AppDomain.CurrentDomain.UnhandledException += (s, e) => {};
18 ManualResetEvent mre = new ManualResetEvent (false);
20 var a = new Action (() => { try { throw new CustomException (); } finally { mre.Set (); } });
21 var ares = a.BeginInvoke (null, null);
23 if (!mre.WaitOne (5000))
24 Environment.Exit (2);
26 try {
27 a.EndInvoke (ares);
28 Environment.Exit (4);
29 } catch (CustomException) {
30 /* expected behaviour */
31 Environment.Exit (255);
32 } catch (Exception ex) {
33 Console.WriteLine (ex);
34 Environment.Exit (3);
37 Environment.Exit (5);