Not able to execute code after exception, it is printing
ccccc
but does not print
AFTER_EXCEPTION
The code is showing the caught exception and then exists.
static void Main(string[] args)
{
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(MyHandler); // using System.Diagnostics;
// Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(OnThreadException);
Process p = Process.GetProcessById(1000);
Console.WriteLine("AFTER_EXCEPTION");
Console.ReadLine();
}
static void MyHandler(object sender, UnhandledExceptionEventArgs args)
{
Console.WriteLine("cccc");
Exception temp = (Exception)args.ExceptionObject;
Console.WriteLine("MyHandler caught : " + temp.Message);
Console.WriteLine("MyHandler caught : " + temp.TargetSite);
}