title: SetConsoleCtrlHandler routine issue
body: <p>I'm writting a console application in C++.</p>
  
  <p>I use SetConsoleCtrlHandler to trap close and CTRL+C button. This allows for all my threads to stop and exit properly.</p>
  
  <p>One of the thread performs some saving that require some time to complete and I have some code to wait in the console crtl handle routine. MSDN specify that a box should pop up after 5 seconds for CTRL_CLOSE_EVENT, but instead my process exits.</p>
  
  <p>This is annoying for debugging console application too as the process exits before you can step through and I don't know what may be the problem (I have Windows 7 64bits).</p>
  
  <p>Also, strangely if my routine returns TRUE (to simply disable the close action), it still closes the application. The routine does get called, so the SetConsoleCtrlHandler was successful installed.</p>
  
  <p>e.g.:</p>
  
  <pre><code>BOOL WINAPI ConsoleHandlerRoutine(DWORD dwCtrlType)
  {
      if (dwCtrlType == CTRL_CLOSE_EVENT)
      {
          return TRUE;
      }
  
      return FALSE;
  }
  
  int _tmain(int argc, _TCHAR* argv[])
  {
      BOOL ret = SetConsoleCtrlHandler(ConsoleHandlerRoutine, TRUE);
  
      while (true)
      {
          Sleep(1000);
      }
      return 0;
  }
  </code></pre>
  
  <p>Any ideas?</p>