This is a tough question to answer in the context of a POSIX timer. The SetTimer window API creates a timer in the GUI thread that relies on the dispatch mechanism of the thread's message queue — which means somewhere in the thread that you call GetMessage / DispatchMessage.
If you are not writing a GUI code, the need to implement a message loop is an unnatural restriction: - The Windows kernel uses synchronization objects (instead of signals) as a way for worker threads (that is, not a GUI) to notify about events. CreateWaitableTimer will create a handle that can be passed to WaitForSingleObject / WaitForMultipleObjects in the workflow.
Alternatively, you can create a workflow - implement a timer in it (GUI or kernel) and simply call an object in your (obviously, it should be thread safe) when the timer is signaled.
The choice really depends on how POSIX will look like your application.
source share