"machine sleep" + WaitForSingleObject + final timeout

A strange question here - but:

If I use WaitForSingleObject on a mutex with a 20 minute timeout. Then the machine goes into sleep mode (or sleep mode) while waiting ... After 12 hours - will my WaitForSingleObject call time out? or does the timer pause during sleep mode?

+6
source share
2 answers

Just tested on Windows 7 with a timeout of 5 minutes and sleeping for 10 minutes. I was waiting for an endless thread.

Surprise - WaitForSingleObject was turned off after my car woke up.

+1
source

According to https://msdn.microsoft.com/en-us/library/windows/desktop/ms687032(v=vs.85).aspx , WaitForSingleObject takes into account the time spent in low-power states, but only starting with Windows 8. So in Windows 7 it should behave as described above, but in Windows 8 and later versions the call will be disconnected only when the system has been actively started for the requested time.

0
source

Source: https://habr.com/ru/post/915257/


All Articles