win32 WaitForSingleObject

参考网页:

https://msdn.microsoft.com/en-us/library/windows/desktop/ms687032(v=vs.85).aspx
Using Mutex Objects (很好的例子)
https://msdn.microsoft.com/en-us/library/windows/desktop/ms686927(v=vs.85).aspx

Waits until the specified object is in the signaled state or the time-out interval elapses.
To enter an alertable wait state, use the WaitForSingleObjectEx function. To wait for multiple objects, use WaitForMultipleObjects.

DWORD WINAPI WaitForSingleObject(
  _In_ HANDLE hHandle,
  _In_ DWORD  dwMilliseconds
);

参数:

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 or the interval elapses. If dwMilliseconds is zero, the function does not enter a wait state if the object is not signaled; it always returns immediately.

当dwMilliseconds = INFINITE的时候,只有当object被激活的时候,才会return

If dwMilliseconds is INFINITE, the function will return only when the object is signaled.
Windows XP, Windows Server 2003, Windows Vista, Windows 7, Windows Server 2008 and Windows Server 2008 R2: The dwMilliseconds value does include time spent in low-power states. For example, the timeout does keep counting down while the computer is asleep.
Windows 8, Windows Server 2012, Windows 8.1, Windows Server 2012 R2, Windows 10 and Windows Server 2016: The dwMilliseconds value does not include time spent in low-power states. For example, the timeout does not keep counting down while the computer is asleep.

返回值

If the function succeeds, the return value indicates the event that caused the function to return. It can be one of the following values.

猜你喜欢

转载自blog.csdn.net/wowocpp/article/details/80533824