社会栋梁 2010-11-10 10:14:05
Queues a work item to a worker thread in the thread pool.
BOOL WINAPI QueueUserWorkItem(
__in LPTHREAD_START_ROUTINE Function,
__in PVOID Context,
__in ULONG Flags
By default, the callback function is queued to a non-I/O worker thread.
The callback function is queued to a thread that uses I/O completion ports, which means they cannot perform an alertable wait. Therefore, if I/O completes and generates an APC, the APC might wait indefinitely because there is no guarantee that the thread will enter an alertable wait state after the callback completes.
The callback function is queued to an I/O worker thread. This thread performs an alertable wait. This is less efficient, so this flag should be used only if the callback generates APCs to the current thread and the APC should be executed after the thread returns to the thread pool.
The callback function is queued as an APC. Be sure to address reentrancy issues if the function performs an alertable wait operation.
The 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 worker threads do not terminate if there are any pending I/O requests.
The callback function can perform a long wait. This flag helps the system to decide if it should create a new thread.
Callback 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 SP2 and Windows Server 2003.