网站首页  词典首页

请输入您要查询的函数:

 

术语 createtimerqueuetimer
释义 CreateTimerQueueTimer
语法:
C++
BOOL WINAPI CreateTimerQueueTimer(
__out PHANDLE phNewTimer,
__in_opt HANDLE TimerQueue,
__in WAITORTIMERCALLBACK Callback,
__in_opt PVOID Parameter,
__in DWORD DueTime,
__in DWORD Period,
__in ULONG Flags
);
CreateTimerQueueTimer Function
创建一个定时器队列计时器。这计时器到期在指定的适当时候,那么,在每一个特定时期。计时器到期时,回调函数被调用。
参数
phNewTimer [out]
阿一个缓冲区,它接收处理回到计时器队列计时器的指针。当此处理已过期,不再需要,通过调用DeleteTimerQueueTimer释放它。
TimerQueue [中,可选]
一个句柄,计时器队列。这种处理是由CreateTimerQueue函数返回。
如果该参数为NULL,定时器,是与默认的定时器队列。
回调 [in]
该申请的指针定义的类型的功能WAITORTIMERCALLBACK被执行时,计时器到期。有关更多信息,请参阅WaitOrTimerCallback。
参数[中,可选]
一个参数值将被传递到回调函数。
DueTime [in]
多少时间流逝计时器之前要设置为首次向信号状态,以毫秒为单位。
期 [in]
定时器的时间,以毫秒为单位。如果此参数为0,定时器信号一次。如果该参数大于零,定时器是周期性的。一个周期性定时器自动重新激活每一个期间满期,直到计时器被取消的时间。
标志 [in]
此参数可以是一个或从WINNT.H中多个下列值。
ValueMeaning
WT_EXECUTEDEFAULT
0x00000000By默认情况下,回调函数是排队到非I / O工作线程。
WT_EXECUTEINTIMERTHREAD
0x00000020The回调函数调用计时器线程本身。这个标志应该只用于短期任务,也可能影响到其他定时器操作。
回调函数是作为的APC队列。它不应该执行报警等待操作。
WT_EXECUTEINIOTHREAD
0x00000001The回调函数是排队一个I / O工作线程。此标志应使用的功能,如果要在一个线程,在一个可报警状态等待执行。
回调函数是作为的APC队列。一定要解决重入问题,如果该函数执行一个可报警等待操作。
WT_EXECUTEINPERSISTENTTHREAD
0x00000080The回调函数是一个线程排队从未终止。它不能保证在同一线程是每次使用。这个标志应该只用于短期任务,也可能影响到其他定时器操作。
请注意,目前没有工作线程是真正持久的,虽然没有工作线程将终止,如果有任何挂起的I / O请求。
WT_EXECUTELONGFUNCTION
0x00000010The回调函数可以执行一个漫长的等待。此标志帮助系统,以决定是否应该创建一个新线程。
WT_EXECUTEONLYONCE
0x00000008The计时器将被设置为有信号状态只有一次。
WT_TRANSFER_IMPERSONATION
0x00000100Callback功能将使用当前的访问令牌,无论是过程或模拟令牌。 If this flag is not specified, callback functions execute only with the process token.
Windows XP/2000操作系统:这个标志是,直到Windows SP2和Windows Server 2003的XP的支持。
返回值
如果函数成功,返回值为非零。
如果函数失败,返回值是零。为了获得更多错误信息,调用GetLastError。
备注
如果DueTime和周期参数都为零,计时器将信号首先在适当的时候,然后定期。回调是每次调用期间满期,是否回调前执行完毕。回调函数排队到线程池。这些线程调度受到延误,因此时间上取决于什么是应用程序或系统发生的事情。
要取消一个计时器,调用DeleteTimerQueueTimer功能。若要取消一个计时器队列中的所有定时器,调用DeleteTimerQueueEx功能。
默认情况下,线程池500最大线程。为了提高这个限制,使用WT_SET_MAX_THREADPOOL_THREAD宏定义在WINNT.H。
#define WT_SET_MAX_THREADPOOL_THREADS(Flags,Limit) \\
((Flags)|=(Limit)<<16)
使用此宏时指定flags参数。该宏的参数所需的旗帜和新的限制(最多(2“”16)-1线程)。但是,请注意您的应用程序可以提高保存的工作线程数量少的表现。
要编译的应用程序使用此功能,定义_WIN32_WINNT为0x0500或更高版本。有关详细信息,请参阅使用Windows头。
实例
举一个例子,它使用CreateTimerQueueTimer,请参阅使用定时器队列。
要求:
最低支持:client-Windows 2000专业版
最低支持server-Windows 2000服务器
HeaderWinbase.h(头文件:winuser.h)
LibraryKernel32.lib
DLLKernel32.dll
参见
CreateTimerQueue
DeleteTimerQueueEx
DeleteTimerQueueTimer
同步功能
线程池
定时器队列
如果有任何问题和意见,请发送给微软(wsddocfb@microsoft.com)
生成日期:2009年8月27日
==英文原文==CreateTimerQueueTimer Function
Creates a timer-queue timer. This timer expires at the specified due time, then after every specified period. When the timer expires, the callback function is called.
Syntax
C++
BOOL WINAPI CreateTimerQueueTimer(
__out PHANDLE phNewTimer,
__in_opt HANDLE TimerQueue,
__in WAITORTIMERCALLBACK Callback,
__in_opt PVOID Parameter,
__in DWORD DueTime,
__in DWORD Period,
__in ULONG Flags
);
Parameters
phNewTimer [out]
A pointer to a buffer that receives a handle to the timer-queue timer on return. When this handle has expired and is no longer required, release it by calling DeleteTimerQueueTimer .
TimerQueue [in, optional]
A handle to the timer queue. This handle is returned by the CreateTimerQueue function.
If this parameter is NULL, the timer is associated with the default timer queue.
Callback [in]
A pointer to the application-defined function of type WAITORTIMERCALLBACK to be executed when the timer expires. For more information, see WaitOrTimerCallback .
Parameter [in, optional]
A single parameter value that will be passed to the callback function.
DueTime [in]
The amount of time to elapse before the timer is to be set to the signaled state for the first time, in milliseconds.
Period [in]
The period of the timer, in milliseconds. If this parameter is zero, the timer is signaled once. If this parameter is greater than zero, the timer is periodic. A periodic timer automatically reactivates each time the period elapses, until the timer is canceled.
Flags [in]
This parameter can be one or more of the following values from Winnt.h.
ValueMeaning
WT_EXECUTEDEFAULT
0x00000000By default, the callback function is queued to a non-I/O worker thread.
WT_EXECUTEINTIMERTHREAD
0x00000020The callback function is invoked by the timer thread itself. This flag should be used only for short tasks or it could affect other timer operations.
The callback function is queued as an APC. It should not perform alertable wait operations.
WT_EXECUTEINIOTHREAD
0x00000001The callback function is queued to an I/O worker thread. This flag should be used if the function should be executed in a thread that waits in an alertable state.
The callback function is queued as an APC. Be sure to address reentrancy issues if the function performs an alertable wait operation.
WT_EXECUTEINPERSISTENTTHREAD
0x00000080The callback function is queued to a thread that never terminates. It does not guarantee that the same thread is used each time. This flag should be used only for short tasks or it could affect other timer operations.
Note that currently no worker thread is truly persistent, although no worker thread will terminate if there are any pending I/O requests.
WT_EXECUTELONGFUNCTION
0x00000010The callback function can perform a long wait. This flag helps the system to decide if it should create a new thread.
WT_EXECUTEONLYONCE
0x00000008The timer will be set to the signaled state only once.
WT_TRANSFER_IMPERSONATION
0x00000100Callback functions will use the current access token, whether it is a process or impersonation token. If this flag is not specified, callback functions execute only with the process token.
Windows XP/2000: This flag is not supported until Windows XP with SP2 and Windows Server 2003.

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
If the DueTime and Period parameters are both nonzero, the timer will be signaled first at the due time, then periodically. The callback is called every time the period elapses, whether or not the previous callback has finished executing. Callback functions are queued to the thread pool. These threads are subject to scheduling delays, so the timing can vary depending on what else is happening in the application or the system.
To cancel a timer, call the DeleteTimerQueueTimer function. To cancel all timers in a timer queue, call the DeleteTimerQueueEx function.
By default, the thread pool has a maximum of 500 threads. To raise this limit, use the WT_SET_MAX_THREADPOOL_THREAD macro defined in Winnt.h.
#define WT_SET_MAX_THREADPOOL_THREADS(Flags,Limit) \\
((Flags)|=(Limit)<<16)
Use this macro when specifying the Flags parameter. The macro parameters are the desired flags and the new limit (up to (2<<16)-1 threads). However, note that your application can improve its performance by keeping the number of worker threads low.
To compile an application that uses this function, define _WIN32_WINNT as 0x0500 or later. For more information, see Using the Windows Headers .
Examples
For an example that uses CreateTimerQueueTimer, see Using Timer Queues .
Requirements
Minimum supported clientWindows 2000 Professional
Minimum supported serverWindows 2000 Server
HeaderWinbase.h (include Windows.h)
LibraryKernel32.lib
DLLKernel32.dll
See Also
CreateTimerQueue
DeleteTimerQueueEx
DeleteTimerQueueTimer
Synchronization Functions
Thread Pooling
Timer Queues
Send comments about this topic to Microsoft
Build date: 8/27/2009
==原始网址==http://msdn.microsoft.com/en-us/library/ms682485(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:27:48