"machine sleep" + WaitForSingleObject + finite timeout

Strange question here -- but:

If I use WaitForSingleObject on a mutex with a 20 minute timeout. Then, the machine enters sleep mode (or hibernate) while waiting.... Upon wake 12 hours later -- will my call to WaitForSingleObject time-out? or will the timer suspend with the machine sleep?


根据https://msdn.microsoft.com/en-us/library/windows/desktop/ms687032(v=vs.85).aspx,WaitForSingleObject确实需要花费在低功耗状态的时间,但只能从Windows 8.所以在Windows 7上,它应该像上面描述的那样工作,但是在Windows 8和更高版本中,只有当系统在所要求的时间内主动运行时,调用才会超时。


Just tested on Windows 7 with 5 minutes timeout and 10 minutes sleep. I was waiting for endless thread.

Surprise - WaitForSingleObject was timed out after my machine waked up.


Excerpt from MSDN:

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.

链接地址: http://www.djcxy.com/p/10714.html

上一篇: 如何从.pac文件找到代理服务器和密码

下一篇: “机器睡眠”+ WaitForSingleObject +有限超时