术语 | waitformultipleobjectsex |
释义 | WaitForMultipleObjectsEx 语法: C++ DWORD WINAPI WaitForMultipleObjectsEx( __in DWORD nCount, __in const HANDLE *lpHandles, __in BOOL bWaitAll, __in DWORD dwMilliseconds, __in BOOL bAlertable ); WaitForMultipleObjectsEx功能 等待,直到一个或多个指定的所有对象是在信号状态,一个I / O完成例程或异步过程调用(APC)是排队到线程,或经过的超时间隔。 参数 nCount [in] 对象句柄数等待数组中所指向的lpHandles。对象句柄的最大数量MAXIMUM_WAIT_OBJECTS。 lpHandles [in] 一个对象的句柄数组。对于一个对象的句柄类型可以指定清单,请参阅下面的备注部分。该阵列可以包含处理不同类型的对象。它不能包含相同的处理多个副本。 如果这些处理一个是封闭,而该等待仍悬而未决,该函数的行为是不确定的。 在处理必须有正确的同步访问。有关更多信息,请参阅标准访问权限。 bWaitAll [in] 如果此参数为TRUE,则函数返回时,在lpHandles数组中的所有对象的状态设置为信号。如果为FALSE,函数返回时,任何一个对象状态设置为信号。在后一种情况下,返回值表示的对象的情况引起的函数返回。 dwMilliseconds的 [in] 在超时间隔时间,以毫秒为单位。如果一个非零值指定的函数等待,直到指定的对象是信号,一个I / O完成例程或APC排队,或经过的时间间隔。如果dwMilliseconds的是零,该函数不进入等待状态,如果条件得不到满足,它总是立即返回。如果dwMilliseconds的是无限的,该函数将返回只有在指定的对象是信号或I / O完成例程或APC排队。 bAlertable [in] 假如该参数为TRUE的线程在等待状态,该函数返回系统队列时,一个I / O完成例程或APC,以及线程运行的日常或功能。否则,该函数不返回的完成例程或APC功能不会被执行。 甲完成例程进行排队时ReadFileEx或WriteFileEx功能,它被指定完成。在等待函数返回的完成例程被调用只有bAlertable为TRUE,调用线程的线程发起读或写操作。排队的APC当您调用QueueUserAPC。 返回值 如果函数成功,返回值表示该事件导致该函数返回。它可以是下列值之一。 (请注意,WAIT_OBJECT_0被定义为0和WAIT_ABANDONED_0是0x00000080L定义。) 返回代码/ valueDescription WAIT_OBJECT_0到(WAIT_OBJECT_0 + nCount - 1)如果bWaitAll为TRUE,则返回值表明,所有指定对象的状态信号。 如果bWaitAll为FALSE,则返回值减去WAIT_OBJECT_0表示满意的是等待的对象lpHandles数组索引。如果多个对象成为在电话信号,这是与所有的信号对象的最小指标值的信号对象的数组索引。 WAIT_ABANDONED_0至(WAIT_ABANDONED_0 + nCount - 1)如果bWaitAll为TRUE,则返回值表明,所有指定对象的状态信号,至少其中一个对象是一个被遗弃的互斥对象。 如果bWaitAll为FALSE,则返回值减去WAIT_ABANDONED_0表明了一个废弃的互斥对象满意等待lpHandles数组索引。对互斥对象的所有权被授予调用线程,而互斥设置为无信号。 如果一个互斥是保护持久状态的信息,您应该检查它的一致性。 WAIT_IO_COMPLETION 0x000000C0LThe等待已结束一个或多个用户模式异步过程调用(APC)的排队到线程。 WAIT_TIMEOUT 0x00000102LThe超时间隔过去了,由bWaitAll参数指定的条件不满意,也没有完成例程进行排队。 WAIT_FAILED (DWORD值)0xFFFFFFFFThe函数失败。为了获得更多错误信息,调用GetLastError。 备注 该WaitForMultipleObjectsEx函数确定是否等待标准已得到满足。如果条件没有得到满足,调用线程进入等待,直到标准的条件下等待状态已经达到或超时间隔经过的。 当bWaitAll为TRUE,函数的等待操作完成,只有在所有对象的状态已被设置为信号。该函数不修改,直到所有对象的国家指定对象的状态已被设置为信号。例如,一个互斥信号可以,但没有得到线程,直到其他物体的国家所有权也将信号。与此同时,其他一些线程可能获得互斥体的所有权,从而确定其状态无信号。 当bWaitAll是FALSE,此功能检查,以便在处理与数组的索引0开始,直到一个对象发出信号。如果多个对象成为暗示,该函数返回首先处理的信号,其目的是数组的索引。 函数修改了某些类型的同步对象的状态。改造只对一个或多个对象的信号状态发生所造成的函数返回。例如,一个信号量对象计数减少1。有关详细信息,请参阅个别同步对象文件。 要等待多MAXIMUM_WAIT_OBJECTS处理,使用下列方法之一: 创建一个线程就MAXIMUM_WAIT_OBJECTS等待句柄,然后等待该加上其他线程处理。使用此技术来打破成MAXIMUM_WAIT_OBJECTS组处理。 呼叫等待RegisterWaitForSingleObject每个处理。从线程池等待线程等待登记的对象和分配一个工作线程对象后,信号或超时间隔过期关于MAXIMUM_WAIT_OBJECTS。 该WaitForMultipleObjectsEx功能可以指定处理的,在下面的对象数组lpHandles任何类型: 更改通知 控制台输入 事件 内存资源通知 互斥 工艺 信号量 线 可等待定时器 使用时要小心调用等待函数和代码直接或间接产生的窗口。如果一个线程创建的窗口,它必须处理消息。广播消息发送到系统中的所有窗口。一个线程使用,没有时间等待功能超时间隔可能会导致系统变得陷入僵局。两个代码,间接创造DDE和窗口的CoInitialize函数的例子。因此,如果您有一个线程创建的窗口,使用,而非WaitForMultipleObjectsEx MsgWaitForMultipleObjects或MsgWaitForMultipleObjectsEx。 要求: 最低支持:client-Windows 2000专业版 最低支持server-Windows 2000服务器 HeaderWinbase.h(头文件:winuser.h) LibraryKernel32.lib DLLKernel32.dll 参见 同步功能 等待函数 如果有任何问题和意见,请发送给微软(wsddocfb@microsoft.com) 生成日期:2009年8月27日 ==英文原文==WaitForMultipleObjectsEx Function Waits until one or all of the specified objects are 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. Syntax C++ DWORD WINAPI WaitForMultipleObjectsEx( __in DWORD nCount, __in const HANDLE *lpHandles, __in BOOL bWaitAll, __in DWORD dwMilliseconds, __in BOOL bAlertable ); Parameters nCount [in] The number of object handles to wait for in the array pointed to by lpHandles. The maximum number of object handles is MAXIMUM_WAIT_OBJECTS. lpHandles [in] An array of object handles. For a list of the object types whose handles can be specified, see the following Remarks section. The array can contain handles of objects of different types. It may not contain multiple copies of the same handle. If one of these handles is closed while the wait is still pending, the function's behavior is undefined. The handles must have the SYNCHRONIZE access right. For more information, see Standard Access Rights . bWaitAll [in] If this parameter is TRUE, the function returns when the state of all objects in the lpHandles array is set to signaled. If FALSE, the function returns when the state of any one of the objects is set to signaled. In the latter case, the return value indicates the object whose state caused the function to return. dwMilliseconds [in] The time-out interval, in milliseconds. If a nonzero value is specified, the function waits until the specified objects are 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 specified objects are 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. (Note that WAIT_OBJECT_0 is defined as 0 and WAIT_ABANDONED_0 is defined as 0x00000080L.) Return code/valueDescription WAIT_OBJECT_0 to (WAIT_OBJECT_0 + nCount– 1)If bWaitAll is TRUE, the return value indicates that the state of all specified objects is signaled. If bWaitAll is FALSE, the return value minus WAIT_OBJECT_0 indicates the lpHandles array index of the object that satisfied the wait. If more than one object became signaled during the call, this is the array index of the signaled object with the smallest index value of all the signaled objects. WAIT_ABANDONED_0 to (WAIT_ABANDONED_0 + nCount– 1)If bWaitAll is TRUE, the return value indicates that the state of all specified objects is signaled, and at least one of the objects is an abandoned mutex object. If bWaitAll is FALSE, the return value minus WAIT_ABANDONED_0 indicates the lpHandles array index of an abandoned mutex object that satisfied the wait. Ownership of the mutex object is granted to the calling thread, and the mutex is set to nonsignaled. If a 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_TIMEOUT 0x00000102LThe time-out interval elapsed, the conditions specified by the bWaitAll parameter were not satisfied, and no completion routines are queued. WAIT_FAILED (DWORD)0xFFFFFFFFThe function has failed. To get extended error information, call GetLastError . Remarks The WaitForMultipleObjectsEx 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. When bWaitAll is TRUE, the function's wait operation is completed only when the states of all objects have been set to signaled. The function does not modify the states of the specified objects until the states of all objects have been set to signaled. For example, a mutex can be signaled, but the thread does not get ownership until the states of the other objects are also set to signaled. In the meantime, some other thread may get ownership of the mutex, thereby setting its state to nonsignaled. When bWaitAll is FALSE, this function checks the handles in the array in order starting with index 0, until one of the objects is signaled. If multiple objects become signaled, the function returns the index of the first handle in the array whose object was signaled. The function modifies the state of some types of synchronization objects. Modification occurs only for the object or objects whose signaled state caused the function to return. For example, the count of a semaphore object is decreased by one. For more information, see the documentation for the individual synchronization objects. To wait on more than MAXIMUM_WAIT_OBJECTS handles, use one of the following methods: Create a thread to wait on MAXIMUM_WAIT_OBJECTS handles, then wait on that thread plus the other handles. Use this technique to break the handles into groups of MAXIMUM_WAIT_OBJECTS. Call RegisterWaitForSingleObject to wait on each handle. A wait thread from the thread pool waits on MAXIMUM_WAIT_OBJECTS registered objects and assigns a worker thread after the object is signaled or the time-out interval expires. The WaitForMultipleObjectsEx function can specify handles of any of the following object types in the lpHandles array: 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 WaitForMultipleObjectsEx. 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/ms687028(VS.85).aspx\n |
随便看 |
|
windows api函数参考手册包含2258条windows api函数文档,详细介绍nodejs、java、rust调用windows api的方法技巧,是学习windows api编程的入门中文文档。