开发者

Signals on Windows

I am writing code in C++ using Win32 API wherever needed. I wish to accomplish the following. When a certain event occurs I want to set an alarm() or start a timer which will send a SIGALRM signal to the process after 1s. The process should continu开发者_JAVA百科e once the alarm has been set. It might so happen that I may have to cancel the alarm (or stop the timer) if certain conditions are met. What system calls can help me do this?


Pseudocode:

// to create a waitable, signallable object
HANDLE myHandle = CreateEvent 

// to wait for 1000ms 
WaitForSingleObject(1000L)    

// to interrupt the wait - check return code on WaitForSingleObject for timeout vs signal
SetEvent(myHandle)

Docs for CreateEvent should get you going.


timeSetEvent and timeKillEvent allow the same functionality on windows

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜