Реорганизация
.NET Core Desktop / build (Debug) (push) Has been cancelled

This commit is contained in:
kislovdm
2026-04-27 00:15:02 +03:00
parent 2fb673661f
commit 8467399001
23 changed files with 77 additions and 88 deletions
@@ -0,0 +1,32 @@
using System;
using System.Runtime.InteropServices;
namespace MonsterMonitor.Services
{
public sealed class PowerManagementService
{
[Flags]
private enum ExecutionState : uint
{
ES_SYSTEM_REQUIRED = 0x00000001,
ES_DISPLAY_REQUIRED = 0x00000002,
ES_CONTINUOUS = 0x80000000
}
[DllImport("kernel32.dll", SetLastError = true)]
private static extern ExecutionState SetThreadExecutionState(ExecutionState flags);
public void PreventSleep()
{
SetThreadExecutionState(
ExecutionState.ES_CONTINUOUS |
ExecutionState.ES_SYSTEM_REQUIRED |
ExecutionState.ES_DISPLAY_REQUIRED);
}
public void RestoreDefault()
{
SetThreadExecutionState(ExecutionState.ES_CONTINUOUS);
}
}
}