public static void SetCurrentSuspendLevel(SuspendLevel level)
        {
            WindowsAPI.EXECUTION_STATE requestedState = 0;
            switch (level)
            {
            case SuspendLevel.AvoidSuspend:
                requestedState = WindowsAPI.EXECUTION_STATE.ES_SYSTEM_REQUIRED;
                break;

            case SuspendLevel.DisplayRequired:
                requestedState = WindowsAPI.EXECUTION_STATE.ES_DISPLAY_REQUIRED;
                break;
            }
            WindowsAPI.SetThreadExecutionState(WindowsAPI.EXECUTION_STATE.ES_CONTINUOUS | requestedState);
        }
        public void SetCurrentSuspendLevel(SuspendLevel level, bool continuous = false)
        {
            WindowsAPI.EXECUTION_STATE requestedState = 0;
            switch (level)
            {
            case SuspendLevel.AvoidSuspend:
                requestedState = WindowsAPI.EXECUTION_STATE.ES_SYSTEM_REQUIRED;
                break;

            case SuspendLevel.DisplayRequired:
                requestedState = WindowsAPI.EXECUTION_STATE.ES_DISPLAY_REQUIRED;
                break;
            }

            if (continuous)
            {
                _lastContinuousSuspendLevel = level; // Remember the value to handle OnQuerySuspend properly
                requestedState |= WindowsAPI.EXECUTION_STATE.ES_CONTINUOUS;
            }

            WindowsAPI.SetThreadExecutionState(requestedState);
        }