Пример #1
0
        /// <summary>
        /// Gets the current windows idle timeout (AC) in minutes.
        /// </summary>
        /// <returns>The current windows idle timeout (AC) in minutes.</returns>
        public static uint GetCurrentWindowsIdleTimeoutAcMinutes()
        {
            var powerPolicy             = PowerSettingsManager.GetCurrentPowerPolicy();
            var winIdleTimeOutAcMinutes = powerPolicy.PowerPolicy.User.IdleTimeoutAc / 60;

            return(winIdleTimeOutAcMinutes);
        }
Пример #2
0
        /// <summary>
        /// Gets the optimal check interval in minutes based on the Windows idle timeout (AC).
        /// </summary>
        /// <returns>The optimal check interval in minutes, but at least 1.</returns>
        public static uint GetOptimalCheckIntervalInMinutes()
        {
            try
            {
                var powerPolicy             = PowerSettingsManager.GetCurrentPowerPolicy();
                var winIdleTimeOutAcMinutes = powerPolicy.PowerPolicy.User.IdleTimeoutAc / 60;

                if (winIdleTimeOutAcMinutes <= 0)
                {
                    winIdleTimeOutAcMinutes = 2; // 2 minutes.
                }
                var optimalCheckInterval = winIdleTimeOutAcMinutes - 1;

                if (optimalCheckInterval <= 0)
                {
                    optimalCheckInterval = 1;
                }

                return(optimalCheckInterval);
            }
            catch (Exception)
            {
                return(WsapmConstants.TimerInterval);
            }
        }
Пример #3
0
 /// <summary>
 /// Gets a value indicating if wake timers are allowed.
 /// </summary>
 /// <returns>True, if wake timers are allowed, otherwise false.</returns>
 public static bool GetWakeTimersAllowed()
 {
     try
     {
         var allowed = PowerSettingsManager.GetWakeTimersAllowed();
         return(allowed);
     }
     catch (Exception)
     {
         return(false);
     }
 }