|
Waitable Timer Objects
A "waitable" timer object is a synchronization object whose state is set to
signaled when the specified due time arrives. There are two types of waitable
timers that can be created: manual-reset and synchronization. A timer of either
type can also be a periodic timer.
Object
| Description
| manual-reset timer
| A timer whose state remains signaled until SetWaitableTimer is called to establish a new due time.
| synchronization timer
| A timer whose state remains signaled until a thread completes a wait operation
on the timer object.
| periodic timer
| A timer that is reactivated each time the specified period expires, until the
timer is reset or canceled. A periodic timer is either a periodic manual-reset
timer or a periodic synchronization timer.
|
A thread uses the CreateWaitableTimer function to create a timer object. Specify TRUE for the bManualReset parameter to create a manual-reset timer and FALSE to create a
synchronization timer. The creating thread can specify a name for the timer object in the lpTimerName parameter. Threads in other processes can open a handle to an existing timer
by specifying its name in a call to the OpenWaitableTimer function. Any thread with a handle to a timer object can use one of the wait functions to wait for the timer state to be set to signaled.
- The thread calls the SetWaitableTimer function to activate the timer. Note the use of the following parameters for SetWaitableTimer:
- Use the lpDueTime parameter to specify the time at which the timer is to be set to the signaled
state. When a manual-reset timer is set to the signaled state, it remains in
this state until SetWaitableTimer establishes a new due time. When a synchronization timer is set to the
signaled state, it remains in this state until a thread completes a wait operation on
the timer object.
- Use the lPeriod parameter of the SetWaitableTimer function to specify the timer period. If the period is not zero, the timer is
a periodic timer; it is reactivated each time the period expires, until the
timer is reset or canceled. If the period is zero, the timer is not a periodic
timer; it is signaled once and then deactivated.
A thread can use the CancelWaitableTimer function to set the timer to the inactive state. To reset the timer, call SetWaitableTimer. When you are finished with the timer object, call CloseHandle to close the handle to the timer object.
Related Links
Software for Delphi and C++ Builder developers
Software for Visual Studio .NET developers
Software for Visual Basic 6 developers
Delphi Tips&Tricks
MegaDetailed.NET
More Online Helps
Win32 Multimedia Programmer's Reference (mmedia.hlp)
OLE Programmer's Reference (ole.hlp)
Microsoft Windows Pen API Programmer's Reference (penapi.hlp)
Microsoft Windows Sockets 2 Reference (sock2.hlp)
Microsoft Windows Telephony API (TAPI) Programmer's Reference (tapi.hlp)
Unix Manual Pages
|