网站首页  词典首页

请输入您要查询的函数:

 

术语 waitforsingleobjectex
释义 WaitForSingleObjectEx
语法:
C++
DWORD WINAPI WaitForSingleObjectEx(
__in HANDLE hHandle,
__in DWORD dwMilliseconds,
__in BOOL bAlertable
);
WaitForSingleObjectEx功能
等待,直到指定的对象是在信号状态,一个I / O完成例程或异步过程调用(APC)是排队到线程,或超时间隔经过的。
等待多个对象,使用WaitForMultipleObjectsEx。
参数
hHandle [in]
句柄的对象。对于一个对象的句柄类型可以指定清单,请参阅下面的备注部分。
如果这个处理是封闭,而该等待仍悬而未决,该函数的行为是不确定的。
句柄必须有正确的同步访问。有关更多信息,请参阅标准访问权限。
dwMilliseconds的 [in]
在超时间隔时间,以毫秒为单位。如果一个非零值指定的函数等待直到该对象发出信号,一个I / O完成例程或APC排队,或经过的时间间隔。如果dwMilliseconds的是零,该函数不进入等待状态,如果条件得不到满足,它总是立即返回。如果dwMilliseconds的是无限的,该函数将返回只有当对象是信号或I / O完成例程或APC排队。
bAlertable [in]
假如该参数为TRUE的线程在等待状态,该函数返回系统队列时,一个I / O完成例程或APC,以及线程运行的日常或功能。否则,该函数不返回,并完成例程或APC功能不会被执行。
甲完成例程进行排队时ReadFileEx或WriteFileEx功能,它被指定完成。在等待函数返回的完成例程被调用只有bAlertable是真的,调用线程的线程发起读或写操作。排队的APC当您调用QueueUserAPC。
返回值
如果函数成功,返回值表示该事件导致该函数返回。它可以是下列值之一。
返回代码/ valueDescription
WAIT_ABANDONED
0x00000080LThe指定的对象是一个互斥对象,即不拥有前拥有线程终止了互斥对象的线程释放。 Ownership of the mutex object is granted to the calling thread and the mutex is set to nonsignaled.
假如是互斥保护的持久状态的信息,您应该检查它的一致性。
WAIT_IO_COMPLETION
0x000000C0LThe等待已结束一个或多个用户模式异步过程调用(APC)的排队到线程。
WAIT_OBJECT_0
指定对象的0x00000000LThe状态信号。
WAIT_TIMEOUT
0x00000102LThe超时时间间隔过去了,该对象的状态是无信号。
WAIT_FAILED
(DWORD值)0xFFFFFFFFThe函数失败。为了获得更多错误信息,调用GetLastError。
备注
该WaitForSingleObjectEx函数确定是否等待标准已得到满足。如果条件没有得到满足,调用线程进入等待,直到标准的条件下等待状态已经达到或超时间隔经过的。
函数修改了某些类型的同步对象的状态。改造不仅对对象的信号状态发生所造成的函数返回。例如,一个信号量对象计数减少1。
该WaitForSingleObjectEx功能可以等待下列对象:
更改通知
控制台输入
事件
内存资源通知
互斥
工艺
信号量
线
可等待定时器
使用时要小心调用等待函数和代码直接或间接产生的窗口。如果一个线程创建的窗口,它必须处理消息。广播消息发送到系统中的所有窗口。一个线程使用,没有时间等待功能超时间隔可能会导致系统变得陷入僵局。两个代码,间接创造DDE和窗口的CoInitialize函数的例子。因此,如果您有一个线程创建的窗口,使用,而非WaitForSingleObjectEx MsgWaitForMultipleObjects或MsgWaitForMultipleObjectsEx。
实例
有关示例,请参见服务器使用命名管道完成例程。
要求:
最低支持:client-Windows 2000专业版
最低支持server-Windows 2000服务器
HeaderWinbase.h(头文件:winuser.h)
LibraryKernel32.lib
DLLKernel32.dll
参见
同步功能
等待函数
如果有任何问题和意见,请发送给微软(wsddocfb@microsoft.com)
生成日期:2009年8月27日
==英文原文==WaitForSingleObjectEx Function
Waits until the specified object is in the signaled state, an I/O completion routine or asynchronous procedure call (APC) is queued to the thread, or the time-out interval elapses.
To wait for multiple objects, use the WaitForMultipleObjectsEx .
Syntax
C++
DWORD WINAPI WaitForSingleObjectEx(
__in HANDLE hHandle,
__in DWORD dwMilliseconds,
__in BOOL bAlertable
);
Parameters
hHandle [in]
A handle to the object. For a list of the object types whose handles can be specified, see the following Remarks section.
If this handle is closed while the wait is still pending, the function's behavior is undefined.
The handle must have the SYNCHRONIZE access right. For more information, see Standard Access Rights .
dwMilliseconds [in]
The time-out interval, in milliseconds. If a nonzero value is specified, the function waits until the object is signaled, an I/O completion routine or APC is queued, or the interval elapses. If dwMilliseconds is zero, the function does not enter a wait state if the criteria is not met; it always returns immediately. If dwMilliseconds is INFINITE, the function will return only when the object is signaled or an I/O completion routine or APC is queued.
bAlertable [in]
If this parameter is TRUE and the thread is in the waiting state, the function returns when the system queues an I/O completion routine or APC, and the thread runs the routine or function. Otherwise, the function does not return, and the completion routine or APC function is not executed.
A completion routine is queued when the ReadFileEx or WriteFileEx function in which it was specified has completed. The wait function returns and the completion routine is called only if bAlertable is TRUE, and the calling thread is the thread that initiated the read or write operation. An APC is queued when you call QueueUserAPC .
Return Value
If the function succeeds, the return value indicates the event that caused the function to return. It can be one of the following values.
Return code/valueDescription
WAIT_ABANDONED
0x00000080LThe specified object is a mutex object that was not released by the thread that owned the mutex object before the owning thread terminated. Ownership of the mutex object is granted to the calling thread and the mutex is set to nonsignaled.
If the mutex was protecting persistent state information, you should check it for consistency.
WAIT_IO_COMPLETION
0x000000C0LThe wait was ended by one or more user-mode asynchronous procedure calls (APC) queued to the thread.
WAIT_OBJECT_0
0x00000000LThe state of the specified object is signaled.
WAIT_TIMEOUT
0x00000102LThe time-out interval elapsed, and the object's state is nonsignaled.
WAIT_FAILED
(DWORD)0xFFFFFFFFThe function has failed. To get extended error information, call GetLastError .

Remarks
The WaitForSingleObjectEx function determines whether the wait criteria have been met. If the criteria have not been met, the calling thread enters the wait state until the conditions of the wait criteria have been met or the time-out interval elapses.
The function modifies the state of some types of synchronization objects. Modification occurs only for the object whose signaled state caused the function to return. For example, the count of a semaphore object is decreased by one.
The WaitForSingleObjectEx function can wait for the following objects:
Change notification
Console input
Event
Memory resource notification
Mutex
Process
Semaphore
Thread
Waitable timer
Use caution when calling the wait functions and code that directly or indirectly creates windows. If a thread creates any windows, it must process messages. Message broadcasts are sent to all windows in the system. A thread that uses a wait function with no time-out interval may cause the system to become deadlocked. Two examples of code that indirectly creates windows are DDE and the CoInitialize function. Therefore, if you have a thread that creates windows, use MsgWaitForMultipleObjects or MsgWaitForMultipleObjectsEx , rather than WaitForSingleObjectEx.
Examples
For an example, see Named Pipe Server Using Completion Routines .
Requirements
Minimum supported clientWindows 2000 Professional
Minimum supported serverWindows 2000 Server
HeaderWinbase.h (include Windows.h)
LibraryKernel32.lib
DLLKernel32.dll
See Also
Synchronization Functions
Wait Functions
Send comments about this topic to Microsoft
Build date: 8/27/2009
==原始网址==http://msdn.microsoft.com/en-us/library/ms687036(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 13:24:50