Platforms to show: All Mac Windows Linux Cross-Platform

WindowsThreadExecutionStateMBS class   New in 23.0

Type Topic Plugin Version macOS Windows Linux iOS Targets
class Windows MBS Win Plugin 23.0 ❌ No ✅ Yes ❌ No ❌ No Desktop, Console & Web
Function: Sets the thread execution state.
Example:

dim flags as integer = WindowsThreadExecutionStateMBS.kSystemRequired
dim w as new WindowsThreadExecutionStateMBS(flags)
window1.WindowsThreadExecutionState = w // store it in property
Notes:
The state is set in constructor and reset in destructor, so you can put this object in a property of a window, so when the window is destroyed, the state is reset automatically.

Enables an application to inform the system that it is in use, thereby preventing the system from entering sleep or turning off the display while the application is running.

For macOS, please check NSProcessInfoMBS class.

The system automatically detects activities such as local keyboard or mouse input, server activity, and changing window focus. Activities that are not automatically detected include disk or CPU activity and video display.

To run properly on a power-managed computer, applications such as fax servers, answering machines, backup agents, and network management applications must use both kSystemRequired when they process events. Multimedia applications, such as video players and presentation applications, must use kDisplayRequired when they display video for long periods of time without user input. Applications such as word processors, spreadsheets, browsers, and games do not need to use this.

The kAwayModeRequired value should be used only when absolutely necessary by media applications that require the system to perform background tasks such as recording television content or streaming media to other devices while the system appears to be sleeping. Applications that do not require critical background processing or that run on portable computers should not enable away mode because it prevents the system from conserving power by entering true sleep.

To enable away mode, an application uses both kAwayModeRequired; to disable away mode, let the destructor reset. When away mode is enabled, any operation that would put the computer to sleep puts it in away mode instead. The computer appears to be sleeping while the system continues to perform tasks that do not require user input. Away mode does not affect the sleep idle timer; to prevent the system from entering sleep when the timer expires, an application must also set the kSystemRequired value.

This class cannot be used to prevent the user from putting the computer to sleep. Applications should respect that the user expects a certain behavior when they close the lid on their laptop or press the power button.

This function does not stop the screen saver from executing.

Flags

Constant Value Description
kAwayModeRequired 64 Enables away mode. 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.
kDisplayRequired 2 Forces the display to be on by resetting the display idle timer.
kSystemRequired 1 Forces the system to be in the working state by resetting the system idle timer.

This class has no sub classes.

Blog Entries


The items on this page are in the following plugins: MBS Win Plugin.


WindowsTaskbarStateMBS   -   WindowsVerticalBlankMBS


💬 Ask a question or report a problem
The biggest plugin in space...


Start Chat