Beispiel #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);
        }
Beispiel #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);
            }
        }