SetConsoleCtrlHandler routine issue

后端 未结 5 869
逝去的感伤
逝去的感伤 2021-02-18 21:43

I\'m writting a console application in C++.

I use SetConsoleCtrlHandler to trap close and CTRL+C button. This allows for all my threads to stop and exit properly.

<
5条回答
  •  粉色の甜心
    2021-02-18 21:56

    Xavier's comment is slightly wrong. Windows 7 allows your code in the event handler ~10 seconds. If you haven't exited the event handler in 10 seconds you are terminated. If you exit the event handler you are terminated immediately. Returning TRUE does not post a dialog. It just exits.

提交回复
热议问题