网站首页  词典首页

请输入您要查询的函数:

 

术语 signalobjectandwait
释义 SignalObjectAndWait
语法:
C++
DWORD WINAPI SignalObjectAndWait(
__in HANDLE hObjectToSignal,
__in HANDLE hObjectToWaitOn,
__in DWORD dwMilliseconds,
__in BOOL bAlertable
);
SignalObjectAndWait功能
原子信号的一个对象和另一个对象等待。
参数
hObjectToSignal [in]
句柄的对象是信号。这个对象可以是一个信号量,互斥,或事件。
如果句柄是一个信号,在SEMAPHORE_MODIFY_STATE探视权是必需的。如果句柄是一个事件,EVENT_MODIFY_STATE探视权是必需的。如果句柄是一个互斥和调用方不拥有互斥,该函数失败,ERROR_NOT_OWNER。
hObjectToWaitOn [in]
句柄的对象等待。同步探视权,需要有更多的信息,请参阅同步对象的安全和访问权限。对于一个对象类型的处理,您可以指定,请参见备注部分名单。
dwMilliseconds的 [in]
在超时间隔时间,以毫秒为单位。函数,如果经过的时间间隔,即使对象的状态是无信号,没有完成或异步过程调用(APC)对象返回排队。如果dwMilliseconds的是零,为排队功能测试完成例程或装甲运兵车对象的状态,检查,并立即返回。如果dwMilliseconds的是无限的,该函数的超时时间间隔从未经过的。
bAlertable [in]
如果此参数为TRUE,则函数返回系统队列时,一个I / O完成例程或APC的功能,以及线程调用该函数。如果为FALSE,函数不返回,而不会调用线程的完成例程或APC的功能。
完成例程进行排队时,函数调用的APC队列已完成。这个函数返回的完成例程被调用只有bAlertable是真的,调用线程的线程排队APC的。
返回值
如果函数成功,返回值表示该事件导致该函数返回。它可以是下列值之一。
返回代码/ valueDescription
WAIT_ABANDONED
0x00000080LThe指定的对象是一个互斥对象,即不拥有前拥有线程终止了互斥对象的线程释放。对互斥对象的所有权被授予调用线程,而互斥设置为无信号。
假如是互斥保护的持久状态的信息,您应该检查它的一致性。
WAIT_IO_COMPLETION
0x000000C0LThe等待已结束一个或多个用户模式异步过程调用(APC)的排队到线程。
WAIT_OBJECT_0
指定对象的0x00000000LThe状态信号。
WAIT_TIMEOUT
0x00000102LThe超时时间间隔过去了,该对象的状态是无信号。
WAIT_FAILED
(DWORD值)0xFFFFFFFFThe函数失败。为了获得更多错误信息,调用GetLastError。
备注
一个线程可以使用此功能,以确保工作线程处于等待状态信号之前的对象。例如,一个线程和一个辅助线程可以使用事件对象句柄同步工作。该线程执行,如下面的代码:
dwRet = WaitForSingleObject(hEventWorkerDone, INFINITE);
if( WAIT_OBJECT_0 == dwRet)
SetEvent(hEventMoreWorkToDo);
The worker thread executes code such as the following:
dwRet = SignalObjectAndWait(hEventWorkerDone,
hEventMoreWorkToDo,
INFINITE,
FALSE);

该SignalObjectAndWait功能可以等待下列对象:
更改通知
控制台输入
事件
内存资源通知
互斥
工艺
信号量
线
可等待定时器
有关更多信息,请参阅同步对象。
使用时要小心使用等待函数和代码直接或间接产生的窗口。如果一个线程创建的窗口,它必须处理消息。广播消息发送到系统中的所有窗口。一个线程使用,没有时间等待功能超时间隔可能会导致系统变得陷入僵局。两个代码,间接创造DDE的窗口和COM CoInitialize例子。因此,如果您有一个线程创建的窗口,一定要调用一个不同的线程SignalObjectAndWait。如果这是不可能的,您可以使用MsgWaitForMultipleObjects或MsgWaitForMultipleObjectsEx,但在功能上是不等价的。
要编译的应用程序使用此功能,定义_WIN32_WINNT为0x0400或更高版本。有关详细信息,请参阅使用Windows头。
要求:
最低支持:client-Windows 2000专业版
最低支持server-Windows 2000服务器
HeaderWinbase.h(头文件:winuser.h)
LibraryKernel32.lib
DLLKernel32.dll
参见
MsgWaitForMultipleObjects
MsgWaitForMultipleObjectsEx
同步功能
等待函数
如果有任何问题和意见,请发送给微软(wsddocfb@microsoft.com)
生成日期:2009年8月27日
==英文原文==SignalObjectAndWait Function
Atomically signals one object and waits on another object.
Syntax
C++
DWORD WINAPI SignalObjectAndWait(
__in HANDLE hObjectToSignal,
__in HANDLE hObjectToWaitOn,
__in DWORD dwMilliseconds,
__in BOOL bAlertable
);
Parameters
hObjectToSignal [in]
A handle to the object to be signaled. This object can be a semaphore, a mutex, or an event.
If the handle is a semaphore, the SEMAPHORE_MODIFY_STATE access right is required. If the handle is an event, the EVENT_MODIFY_STATE access right is required. If the handle is a mutex and the caller does not own the mutex, the function fails with ERROR_NOT_OWNER.
hObjectToWaitOn [in]
A handle to the object to wait on. The SYNCHRONIZE access right is required; for more information, see Synchronization Object Security and Access Rights . For a list of the object types whose handles you can specify, see the Remarks section.
dwMilliseconds [in]
The time-out interval, in milliseconds. The function returns if the interval elapses, even if the object's state is nonsignaled and no completion or asynchronous procedure call (APC) objects are queued. If dwMilliseconds is zero, the function tests the object's state, checks for queued completion routines or APCs, and returns immediately. If dwMilliseconds is INFINITE, the function's time-out interval never elapses.
bAlertable [in]
If this parameter is TRUE, the function returns when the system queues an I/O completion routine or APC function, and the thread calls the function. If FALSE, the function does not return, and the thread does not call the completion routine or APC function.
A completion routine is queued when the function call that queued the APC has completed. This function returns and the completion routine is called only if bAlertable is TRUE, and the calling thread is the thread that queued the APC.
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
A thread can use this function to ensure that a worker thread is in a wait state before signaling an object. For example, a thread and a worker thread may use handles to event objects to synchronize their work. The thread executes code such as the following:
dwRet = WaitForSingleObject(hEventWorkerDone, INFINITE);
if( WAIT_OBJECT_0 == dwRet)
SetEvent(hEventMoreWorkToDo);
The worker thread executes code such as the following:
dwRet = SignalObjectAndWait(hEventWorkerDone,
hEventMoreWorkToDo,
INFINITE,
FALSE);
The SignalObjectAndWait function can wait for the following objects:
Change notification
Console input
Event
Memory resource notification
Mutex
Process
Semaphore
Thread
Waitable timer
For more information, see Synchronization Objects .
Use caution when using 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 COM CoInitialize. Therefore, if you have a thread that creates windows, be sure to call SignalObjectAndWait from a different thread. If this is not possible, you can use MsgWaitForMultipleObjects or MsgWaitForMultipleObjectsEx , but the functionality is not equivalent.
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
MsgWaitForMultipleObjects
MsgWaitForMultipleObjectsEx
Synchronization Functions
Wait Functions
Send comments about this topic to Microsoft
Build date: 8/27/2009
==原始网址==http://msdn.microsoft.com/en-us/library/ms686293(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:23:39