/// <summary> /// Allows an application to inform the system that it /// is in use, thereby preventing the system from entering /// the sleeping power state or turning off the display /// while the application is running. /// </summary> /// <param name="executionStateOptions">The thread's execution requirements.</param> /// <exception cref="Win32Exception">Thrown if the SetThreadExecutionState call fails.</exception> public static void SetThreadExecutionState(ExecutionStates executionStateOptions) { ExecutionStates ret = PowerManagementNativeMethods.SetThreadExecutionState(executionStateOptions); if (ret == ExecutionStates.None) { throw new Win32Exception(LocalizedMessages.PowerExecutionStateFailed); } }
/// <summary> /// Allows an application to inform the system that it /// is in use, thereby preventing the system from entering /// the sleeping power state or turning off the display /// while the application is running. /// </summary> /// <param name="flags">The thread's execution requirements.</param> /// <exception cref="Win32Exception">Thrown if the SetThreadExecutionState call fails.</exception> internal static void SetThreadExecutionState(ExecutionState flags) { ExecutionState?ret = PowerManagementNativeMethods.SetThreadExecutionState(flags); if (ret == null) { throw new Win32Exception("SetThreadExecutionState call failed."); } }