2 using System.Diagnostics;
3 using System.Threading;
4 using System.Threading.Tasks;
6 class CustomException : Exception
10 class CustomException2 : Exception
16 /* expected exit code: 0 */
17 static void Main (string[] args)
19 ManualResetEvent mre = new ManualResetEvent (false);
20 ManualResetEvent mre2 = new ManualResetEvent (false);
22 var a = new Action (() => { try { throw new CustomException (); } finally { mre.Set (); } });
23 var ares = a.BeginInvoke (_ => { mre2.Set (); throw new CustomException2 (); }, null);
25 if (!mre.WaitOne (5000))
27 if (!mre2.WaitOne (5000))
28 Environment.Exit (22);
33 } catch (CustomException) {
34 } catch (Exception ex) {
35 Console.WriteLine (ex);