-
December 14th, 2008, 05:57 AM
#1
SetWaitableTimer confusions
Hello everyone,
For SetWaitableTimer and CreateWaitableTimer, I have the confusions (even after Google, I can not find satisfied answers, seems the samples are very few and MSDN description is fuzzy).
My questions are,
1. For API SetWaitableTimer, what are the meaning and function of parameters pDueTime and lPeriod?
http://msdn.microsoft.com/en-us/library/ms686289.aspx
2. For API CreateWaitableTimer, what is the function and meaning of parameter bManualReset (what is the different between setting it to true and setting it to false)?
http://msdn.microsoft.com/en-us/library/ms682492.aspx
thanks in advance,
George
-
December 14th, 2008, 06:56 AM
#2
Re: SetWaitableTimer confusions
pDueTime defines time when a timer ticks first time. lPeriod defines whether timer is periodic, and timer interval, after first timer tick. 0 - timer ticks only once. For example:
LARGE_INTEGER liDueTime;
liDueTime.QuadPart=-100000000;
...
// Set a timer to wait for 10 seconds.
SetWaitableTimer(hTimer, &liDueTime, 0, NULL, NULL, 0)
bManualReset = FALSE.
Such timer becomes unsignaled automatically when single thread Wait operator succeeds. This means, client which calls WiitForSignalObject for a timer, doesn't need to reset this timer after successful wait operation.
bManualReset = TRUE.
After wait operation timer should be reset. It is possible that more than one threads may successfully wait for the same timer.
-
December 14th, 2008, 07:43 AM
#3
Re: SetWaitableTimer confusions
Thanks Alex,
Originally Posted by Alex F
bManualReset = FALSE.
Such timer becomes unsignaled automatically when single thread Wait operator succeeds. This means, client which calls WiitForSignalObject for a timer, doesn't need to reset this timer after successful wait operation.
bManualReset = TRUE.
After wait operation timer should be reset. It is possible that more than one threads may successfully wait for the same timer.
One more question about bManualReset parameter. In my limited experience, when we synchronize operations between multiple threads, we wait on events. I do not know what do you mean wait on timer? Could you clarify or refer to some simple sampels please?
regards,
George
-
December 15th, 2008, 08:11 AM
#4
Re: SetWaitableTimer confusions
Hi!
Just like you can wait on an event, you can also wait on a timer.
Read the remarks in the WaitForSingleObject docs and you will understand.
http://msdn.microsoft.com/en-us/libr...32(VS.85).aspx
Nobody cares how it works as long as it works
-
December 30th, 2008, 06:54 AM
#5
Re: SetWaitableTimer confusions
Cool, zerver!
Originally Posted by zerver
regards,
George
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|