views:

657

answers:

2

I'm attempting to keep the system on while allowing the display to power off, to allow a download to finish while the system is unattended. To achieve this I call:

SetThreadExecutionState(ES_SYSTEM_REQUIRED);

whenever I get data from the download. However, this seems to prevent display power down as well (the display dims per its configured dimming timer, but never completely turns off). According to the MSDN entry, this should only happen if I also pass ES_DISPLAY_REQUIRED - why is it being blocked anyway?

Note that when I stop calling SetThreadExecutionState, the display does not start powering off again; I have to terminate the program to allow the display to turn off. However, shouldn't it only have persistent effects if called with ES_CONTINUOUS?

I'm using Windows 7, if it matters. I'm unable to test on other versions at this time...

A: 

Never mind - it appears the bug wasn't in my code :)

bdonlan
A: 

if you call this function without ES_CONTINUOUS, it will not continue counting the idle timer for system and monitor. so you must pass the parameters with combination by ES_CONTINUOUS. for example you can call SetThreadExecutionState(ES_SYSTEM_REQUIRED | ES_CONTINUOUS); instead of SetThreadExecutionState(ES_SYSTEM_REQUIRED);

Sajad Beigjani
Hi, that was not my original problem - but the premise of the question is flawed, so I'll petition the mods to delete the question.
bdonlan