Can I use a SetTimer() API in a console C++ application?

后端 未结 6 999
予麋鹿
予麋鹿 2020-12-09 22:08

I have a console application that is using a DLL file that uses a SetTimer() call to create a timer and fire a function within itself. The call is below:

<
6条回答
  •  没有蜡笔的小新
    2020-12-09 22:19

    Timers set using the SetTimer API require a Windows message processing function to be actively running, as that is where the time messages are sent.

    If you need a timer thread then you could register a Window class and create a default window message pump (See this article for a short example), but a simpler process would probably be to just spin up a second thread to handle your timing events and send notifications.

提交回复
热议问题