question

osvbnet avatar image
0 Votes"
osvbnet asked XiaopoYang-MSFT answered

Advise on SetThreadExecutionState needed

Hello,
When preventing system sleep using this function:

https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-setthreadexecutionstate

The documentation advises to use ES_AWAYMODE_REQUIRED with caution for media apps only!

  1. But does not explain the difference between ES_AWAYMODE_REQUIRED and ES_DISPLAY_REQUIRED+ES_SYSTEM_REQUIRED

  2. A Blu-ray burning app is considered as media app allowed to use ES_AWAYMODE_REQUIRED?

  3. A data processing CPU/Disk intensive app is also considered as media app allowing ES_AWAYMODE_REQUIRED?

Thanks for advise :)

windows-apidotnet-visual-basic
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

XiaopoYang-MSFT avatar image
0 Votes"
XiaopoYang-MSFT answered

According to SetThreadExecutionState,
ES_DISPLAY_REQUIRED+ES_SYSTEM_REQUIRED Forces the display to be on by resetting the display idle timer once and Forces the system to be in the working state by resetting the system idle timer once.
ES_AWAYMODE_REQUIRED Away mode should be used only by media-recording and media-distribution applications that must perform critical background processing on desktop computers while the computer appears to be sleeping.

I suppose media-recording and media-distribution applications mentioned is just for explanation. The clue is critical background processing.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.