网站首页  词典首页

请输入您要查询的函数:

 

术语 setwaitabletimer
释义 SetWaitableTimer
语法:
C++
BOOL WINAPI SetWaitableTimer(
__in HANDLE hTimer,
__in const LARGE_INTEGER *pDueTime,
__in LONG lPeriod,
__in_opt PTIMERAPCROUTINE pfnCompletionRoutine,
__in_opt LPVOID lpArgToCompletionRoutine,
__in BOOL fResume
);
SetWaitableTimer功能
激活指定的可等待计时器。当适当的时间到达时,计时器,并发出信号的线程设置计时器调用可选的完成例程。
参数
hTimer [in]
一个句柄,计时器对象。在CreateWaitableTimer或OpenWaitableTimer函数返回此句柄。
句柄必须有TIMER_MODIFY_STATE访问权限。有关更多信息,请参阅同步对象的安全和访问权限。
pDueTime [in]
之后的时间定时器的状态设置为100纳秒信号间隔。使用由FILETIME结构描述的格式。正值表示绝对时间。请务必使用一个星期日为基础的绝对时间,因为系统使用UTC的时间在内部。负值表示相对时间。实际计时器的精确度取决于您的硬件能力。如需有关星期日信息化时,看到系统时间。
lPeriod [in]
定时器的时间,以毫秒为单位。如果lPeriod是零,计时器发出信号一次。如果lPeriod大于零,定时器是周期性的。一个周期性定时器自动重新激活,每次期间满期,直到计时器被取消使用CancelWaitableTimer函数或重新使用SetWaitableTimer。如果lPeriod小于零,函数失败。
pfnCompletionRoutine [中,可选]
对一个可选的完成例程的指针。完成例程的应用程序定义的类型的功能PTIMERAPCROUTINE被执行时,计时器的信号。欲了解更多有关计时器回调函数信息,请TimerAPCProc。
lpArgToCompletionRoutine [中,可选]
一个传递给完成例程结构的指针。
fResume [in]
如果此参数为TRUE,恢复了中断系统的节能模式,当计时器状态设置为信号。否则,该系统无法恢复。如果系统不支持恢复,调用成功,但GetLastError返回ERROR_NOT_SUPPORTED。
返回值
如果函数成功,返回值为非零。
如果函数失败,返回值是零。为了获得更多错误信息,调用GetLastError。
备注
计时器最初活跃。要启动一个计时器,请SetWaitableTimer。如果计时器已经积极当调用SetWaitableTimer,计时器停止,那么它重新启动。停止计时器以这种方式不设置计时器状态信号,在等待操作上阻塞线程的计时器,仍然受阻。但是,它取消任何尚待完成例程。
由于在指定的时间到达时,计时器就会变成无效的APC是排队的线程设置计时器。定时器的状态设置为信号,计时器重新使用指定的时期,线程计时器设置完成例程调用时,进入一个可报警等待状态。如果计时器在线程设置进入一个可报警等待状态中,APC被取消。有关更多信息,请参阅QueueUserAPC。
如果线程设置计时器终止,有一个关联的完成例程,计时器被取消。然而,定时器的状态保持不变。如果没有完成例程,然后终止该线程不会对计时器的影响。
当手动复位定时器设置为信号状态,是它至今仍然SetWaitableTimer称为重置计时器处于这种状态。因此,定期手动复位定时器设置为信号状态时,及时到达最初,仍然暗示,直到它被重置。当同步计时器设置为信号状态,但仍然有效,直到一个线程完成的计时器对象的等待操作处于这种状态。
如果系统时间调整,对任何未适当的时候绝对计时器调整。
如果是所谓的SetWaitableTimer退出线程,计时器被取消。这将停止才能设置为信号状态,并取消优秀装甲运兵车计时器,它不会改变定时器的信号状态。
实例
举一个例子,它使用SetWaitableTimer,请参阅使用可等待定时器对象。
要编译的应用程序使用此功能,定义_WIN32_WINNT为0x0400或更高版本。有关详细信息,请参阅使用Windows头。
要求:
最低支持:client-Windows 2000专业版
最低支持server-Windows 2000服务器
HeaderWinbase.h(头文件:winuser.h)
LibraryKernel32.lib
DLLKernel32.dll
参见
CancelWaitableTimer
CreateWaitableTimer
OpenWaitableTimer
同步功能
TimerAPCProc
可等待定时器对象
如果有任何问题和意见,请发送给微软(wsddocfb@microsoft.com)
生成日期:2009年8月27日
==英文原文==SetWaitableTimer Function
Activates the specified waitable timer. When the due time arrives, the timer is signaled and the thread that set the timer calls the optional completion routine.
Syntax
C++
BOOL WINAPI SetWaitableTimer(
__in HANDLE hTimer,
__in const LARGE_INTEGER *pDueTime,
__in LONG lPeriod,
__in_opt PTIMERAPCROUTINE pfnCompletionRoutine,
__in_opt LPVOID lpArgToCompletionRoutine,
__in BOOL fResume
);
Parameters
hTimer [in]
A handle to the timer object. The CreateWaitableTimer or OpenWaitableTimer function returns this handle.
The handle must have the TIMER_MODIFY_STATE access right. For more information, see Synchronization Object Security and Access Rights .
pDueTime [in]
The time after which the state of the timer is to be set to signaled, in 100 nanosecond intervals. Use the format described by the FILETIME structure. Positive values indicate absolute time. Be sure to use a UTC-based absolute time, as the system uses UTC-based time internally. Negative values indicate relative time. The actual timer accuracy depends on the capability of your hardware. For more information about UTC-based time, see System Time .
lPeriod [in]
The period of the timer, in milliseconds. If lPeriod is zero, the timer is signaled once. If lPeriod is greater than zero, the timer is periodic. A periodic timer automatically reactivates each time the period elapses, until the timer is canceled using the CancelWaitableTimer function or reset using SetWaitableTimer. If lPeriod is less than zero, the function fails.
pfnCompletionRoutine [in, optional]
A pointer to an optional completion routine. The completion routine is application-defined function of type PTIMERAPCROUTINE to be executed when the timer is signaled. For more information on the timer callback function, see TimerAPCProc .
lpArgToCompletionRoutine [in, optional]
A pointer to a structure that is passed to the completion routine.
fResume [in]
If this parameter is TRUE, restores a system in suspended power conservation mode when the timer state is set to signaled. Otherwise, the system is not restored. If the system does not support a restore, the call succeeds, but GetLastError returns ERROR_NOT_SUPPORTED.
Return Value
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero. To get extended error information, call GetLastError.
Remarks
Timers are initially inactive. To activate a timer, call SetWaitableTimer. If the timer is already active when you call SetWaitableTimer, the timer is stopped, then it is reactivated. Stopping the timer in this manner does not set the timer state to signaled, so threads blocked in a wait operation on the timer remain blocked. However, it does cancel any pending completion routines.
When the specified due time arrives, the timer becomes inactive and the APC is queued to the thread that set the timer. The state of the timer is set to signaled, the timer is reactivated using the specified period, and the thread that set the timer calls the completion routine when it enters an alertable wait state. If the timer is set before the thread enters an alertable wait state, the APC is canceled. For more information, see QueueUserAPC .
If the thread that set the timer terminates and there is an associated completion routine, the timer is canceled. However, the state of the timer remains unchanged. If there is no completion routine, then terminating the thread has no effect on the timer.
When a manual-reset timer is set to the signaled state, it remains in this state until SetWaitableTimer is called to reset the timer. As a result, a periodic manual-reset timer is set to the signaled state when the initial due time arrives and remains signaled until it is reset. 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.
If the system time is adjusted, the due time of any outstanding absolute timers is adjusted.
If the thread that called SetWaitableTimer exits, the timer is canceled. This stops the timer before it can be set to the signaled state and cancels outstanding APCs; it does not change the signaled state of the timer.
Examples
For an example that uses SetWaitableTimer, see Using Waitable Timer Objects .
To compile an application that uses this function, define _WIN32_WINNT as 0x0400 or later. For more information, see Using the Windows Headers .
Requirements
Minimum supported clientWindows 2000 Professional
Minimum supported serverWindows 2000 Server
HeaderWinbase.h (include Windows.h)
LibraryKernel32.lib
DLLKernel32.dll
See Also
CancelWaitableTimer
CreateWaitableTimer
OpenWaitableTimer
Synchronization Functions
TimerAPCProc
Waitable Timer Objects
Send comments about this topic to Microsoft
Build date: 8/27/2009
==原始网址==http://msdn.microsoft.com/en-us/library/ms686289(VS.85).aspx\n
随便看

 

windows api函数参考手册包含2258条windows api函数文档,详细介绍nodejs、java、rust调用windows api的方法技巧,是学习windows api编程的入门中文文档。

 

Copyright © 2004-2023 Winrtm.com All Rights Reserved
京ICP备2021023879号-40 更新时间:2024/10/6 11:25:59