You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Runtime.InteropServices;
- using System.Text;
- using System.Threading.Tasks;
-
- namespace BPASmartClient.MorkT
- {
- public class PreventSleep
- {
- [DllImport("kernel32.dll")]
- static extern uint SetThreadExecutionState(uint dwThreadId);
- const uint ES_SYSTEM_REQUIRED = 0x00000001;
- const uint ES_DISPLAY_REQUIRED = 0x00000002;
- const uint ES_CONTINUOUS = 0x80000000;
-
- public static void SleepControl(bool isSleep)
- {
- if (isSleep)
- {
- SetThreadExecutionState(ES_CONTINUOUS | ES_DISPLAY_REQUIRED | ES_SYSTEM_REQUIRED);
- }
- else
- {
- SetThreadExecutionState(ES_CONTINUOUS);
- }
- }
- }
- }
|