This function returns when the specified object is in the signaled state or when the time-out interval elapses.<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
当指定对象处于可触发状态或间隔时间超时,该函数返回。
<?xml:namespace prefix = v ns = "urn:schemas-microsoft-com:vml" /> Syntax
DWORD WaitForSingleObject(
HANDLE hHandle,
DWORD dwMilliseconds
);
Parameters
参数
hHandle
[in] Handle to the object. For a list of the object types whose handles can be specified, see the Remarks section.
【输入】指向对象的句柄,对于可以被指定句柄的对象类型类表,请参考备注部分。
dwMilliseconds
[in] Specifies the time-out interval, in milliseconds. The function returns if the interval elapses, even if the object's state is nonsignaled. If dwMilliseconds is zero, the function tests the object's state and returns immediately. If dwMilliseconds is INFINITE, the function's time-out interval never elapses.
【输入】指定时间间隔,已毫秒为单位。如果间隔时间超时,即使时间对象为不可触发状态,则函数返回。如果参数值为0,该函数立即返回用来测试对象状态。如果参数为INFINITE,则函数的时间间隔永不超时。
[in] Handle to the object. For a list of the object types whose handles can be specified, see the Remarks section.
dwMilliseconds
[in] Specifies the time-out interval, in milliseconds. The function returns if the interval elapses, even if the object's state is nonsignaled. If dwMilliseconds is zero, the function tests the object's state and returns immediately. If dwMilliseconds is INFINITE, the function's time-out interval never elapses.
Return Value
返回值
If the function succeeds, the return value indicates the event that caused the function to return. The following table shows possible values.
如果函数调用成功,返回值指定导致函数返回的事件。下表为可能的返回值。
Value | Description |
WAIT_FAILED | Indicates failure for one of the following reasons: 指示为以下失败的原因 · There is insufficient memory in the system. · 系统内存不足 · Two threads are waiting on the same interrupt event. · 两个线程等待相同的中断时间 · The current thread is being terminated. · 当前线程将被终止 · The underlying object represented by hHandle has been deleted. · 基本的对象hHandle代表已被删除。 · The handle is invalid. · 句柄不可用 ·
|
WAIT_OBJECT_0 | The state of the specified object is signaled. 指定对象的状态时可触发的。 |
WAIT_TIMEOUT | The time-out interval elapsed, and the object's state is nonsignaled. 间隔时间超时,并且对象状态时不可触发。 |
To get extended error information, call GetLastError.
Remarks
The function checks the current state of the specified object. If the object's state is nonsignaled, the calling thread enters an efficient wait state. The thread consumes very little processor time while waiting for the object state to become signaled or the time-out interval to elapse. The time-out value needs to be a positive number between zero and 0x7FFFFFFF. The maximum time-out value not equal to infinity is 0x7FFFFFFF. The infinite time-out value is 0xFFFFFFFF. Any time-out value between 0x7FFFFFFF and 0xFFFFFFFF — that is, values from 0x80000000 through 0xFFFFFFFE — is equivalent to 0x7FFFFFFF. If you need a bigger time-out value than the maximum of 0x7FFFFFFF, use the value for infinity (0xFFFFFFFF).
这个函数检查指定对象的当前状态。如果对象的状态为不可触发的。则调用线程进入一个高效率等待状态。在等待事件对象变为可触发或间隔时间超时,线程消耗很少的处理时间。间隔时间值必须是一个在0到0x7fffffff之间的正数。最大间隔时间值是0x7fffffff,不等于无限长。无限长时间间隔值是0xffffffff。任何在0x7fffffff和0xffffffff之间的间隔时间值,就是说,在0x80000000到0xffffffff 都等效为0x7fffffff。如果需要一个比最大间隔时间0x7fffffff大的时间间隔实用的无限长值0xffffffff。
Requirements
winbase.h | |
Library | coredll.lib |
Windows Embedded CE | Windows CE 1.0 and later |
Windows Mobile | Windows Mobile Version 5.0 and later |
文章评论(0条评论)
登录后参与讨论