title: When will AppDomain.ProcessExit not get called?
body: <p>Enabling line <code>//1</code> below will make the program crash without "proc exit" being printed,
  but in case of line <code>//2</code>, "proc exit" will be printed. "unhandled" btw gets printed in both cases.</p>
  
  <p>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?</p>
  
  <pre><code>static void Main(string[] args)
  {
      Thread.GetDomain().UnhandledException +=
          (sender, eventArgs) =&gt; Console.WriteLine("unhandled");
      AppDomain.CurrentDomain.ProcessExit +=
          (sender, eventArgs) =&gt; Console.WriteLine("proc exit");
      //1 new Thread(_ =&gt; { throw new Exception(); }).Start();
      //2 ThreadPool.QueueUserWorkItem(_ =&gt; { throw new Exception(); });
      Thread.Sleep(1000);
      return;
  </code></pre>