win32 WaitForSingleObject

本文详细介绍了Windows API函数 WaitForSingleObject 的使用方法,包括其参数解释、返回值含义及不同操作系统中时间间隔计数规则。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

参考网页:

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.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值