title: Does TThread work differently in a Delphi 2006 console application?
body: <p>We have a pretty mature COM dll, which we test using DUnit. One of our recent tests creates a few threads, and tests the object from those threads. This test works fine when running the test using the gui front-end, but hangs when running as a console application. Here's a quick pseudo view of what we have in the test</p>
  
  <pre><code>SetupTest;
  fThreadRefCount := 0; //number of active threads
  Thread1 := TMyThread.Create(True);
  Inc(fThreadRefCount);
  Thread1.OnTerminate := HandleTerminate; //HandleOnTerminate decrements fThreadRefCount
  Thread3 := TMyThread.Create(True);
  Inc(fThreadRefCount);
  Thread2.OnTerminate := HandleTerminate; //HandleOnTerminate decrements fThreadRefCount
  Thread3 := TMyThread.Create(True);
  Inc(fThreadRefCount);
  Thread3.OnTerminate := HandleTerminate; //HandleOnTerminate decrements fThreadRefCount
  
  Thread1.Resume;
  Thread2.Resume;
  Thread3.Resume;
  
  while fThreadRefCount &gt; 0 do
    Application.ProcessMessages;
  </code></pre>
  
  <p>I have tried doing nothing in the OnExecute, so I'm sure it's not the actual code I'm testing. In the console, fThreadRefCount never decrements, while if I run it as a gui app, it's fine!</p>
  
  <p>As far as I can see, the OnTerminate event is just not called.</p>