Example #1
0
        public void ClearPowerManagementOverrides()
        {
            var result =
                WindowsPowerManagementApi.SetThreadExecutionState(WindowsPowerManagementApi.EXECUTION_STATE.ES_CONTINUOUS);

            if (result == 0)
            {
                throw new Win32Exception();
            }
        }
Example #2
0
        public void PreventSleep()
        {
            var result = WindowsPowerManagementApi.SetThreadExecutionState(
                WindowsPowerManagementApi.EXECUTION_STATE.ES_SYSTEM_REQUIRED
                | WindowsPowerManagementApi.EXECUTION_STATE.ES_CONTINUOUS);

            if (result == 0)
            {
                throw new Win32Exception();
            }
        }