Please review this console application shortcode.
static void Main(string[] args) { try { Action a = () => { throw new ApplicationException("Oops"); }; var ar = a.BeginInvoke(null, null); ar.AsyncWaitHandle.WaitOne(); try { a.EndInvoke(ar); Console.WriteLine("No message"); } catch (Exception e) { Console.WriteLine(e.Message); } } finally { Console.ReadKey(); } }
When launched, Visual Studio will be broken into throw
, complaining that its raw. When executed outside the debugger, the code does what I expect (displays "Oops").
How to convince Visual Studio to allow code execution, as it would in the real world?
source share