Advise on SetThreadExecutionState needed

OSVBNET 1,386 Reputation points
2022-05-27T21:04:23.883+00:00

Hello,
When preventing system sleep using this function:

https://learn.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 API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,432 questions
VB
VB
An object-oriented programming language developed by Microsoft that is implemented on the .NET Framework. Previously known as Visual Basic .NET.
2,585 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Xiaopo Yang - MSFT 11,501 Reputation points Microsoft Vendor
    2022-05-30T03:06:07.633+00:00

    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.

    0 comments No comments