Enabling line //1 below will make the program crash without "proc exit" being printed,
but in case of line //2, "proc exit" will be printed. "unhandled" btw gets printed in both cases.
Why the difference, and what are the rules in general? Obviously killing an app using e.g. the task manager will prevent "proc exit" from being printed, but other than that, what are the cases it doesn't get printed?
static void Main(string[] args)
{
Thread.GetDomain().UnhandledException +=
(sender, eventArgs) => Console.WriteLine("unhandled");
AppDomain.CurrentDomain.ProcessExit +=
(sender, eventArgs) => Console.WriteLine("proc exit");
//1 new Thread(_ => { throw new Exception(); }).Start();
//2 ThreadPool.QueueUserWorkItem(_ => { throw new Exception(); });
Thread.Sleep(1000);
return;