Last active
July 4, 2025 11:14
Revisions
-
brianhassel renamed this gist
Aug 21, 2015 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
brianhassel created this gist
Aug 21, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,21 @@ internal static class NativeMethods { public static void PreventSleep() { SetThreadExecutionState(ExecutionState.EsContinuous | ExecutionState.EsSystemRequired); } public static void AllowSleep() { SetThreadExecutionState(ExecutionState.EsContinuous); } [DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)] private static extern ExecutionState SetThreadExecutionState(ExecutionState esFlags); [FlagsAttribute] private enum ExecutionState : uint { EsAwaymodeRequired = 0x00000040, EsContinuous = 0x80000000, EsDisplayRequired = 0x00000002, EsSystemRequired = 0x00000001 } }