コード例 #1
0
        /// <summary>
        /// Start the resume automatic timer.
        /// </summary>
        /// <remarks>This has to be done in order to prevent system entering standby after a few minutes after the ResumeAutomatic event when no ResumeSuspend event follows,
        /// i.e. system is woken, but user is not present.</remarks>
        private void StartResumeAutomaticTimer()
        {
            // Only start resume automatic timer if system was really woken by WSAPM timer.
            // Otherwise the system is already running when the wake timer elapses.
            if (!SystemWokenByWakeTimer())
            {
                return;
            }

            StopResumeAutomaticTimer();
            this.resumeAutomaticTimer = new Timer();

            // The resumeAutomaticTimer's interval has to be shorter than the Wsapm's timer!
            var interval = TimeSpan.FromMinutes(WsapmTools.GetCurrentWindowsIdleTimeoutAcMinutes()).TotalMilliseconds;

            if (this.monitoringTimer != null)
            {
                var delay = TimeSpan.FromSeconds(10).TotalMilliseconds;
                interval = this.monitoringTimer.Interval - delay;
            }

            SuspendStandby(new CheckSuspendResult(true, string.Format(Resources.Wsapm_Core.WsapmManager_TimerStartedAfterResumeAutomatic, TimeSpan.FromMilliseconds(interval).TotalMinutes.ToString("00"))));
            this.resumeAutomaticTimer.Interval  = interval;
            this.resumeAutomaticTimer.Elapsed  += resumeAutomaticTimer_Elapsed;
            this.resumeAutomaticTimer.AutoReset = false;
            this.resumeAutomaticTimer.Start();
        }
コード例 #2
0
        /// <summary>
        /// Validates the given settings.
        /// </summary>
        /// <param name="settings"></param>
        private void ValidateSettings(WsapmSettings settings)
        {
            // Validate settings and print warning when needed.
            if (!WsapmTools.ValidateCheckInterval(settings))
            {
                var winIdleTimeoutAcMinutes = WsapmTools.GetCurrentWindowsIdleTimeoutAcMinutes();
                WsapmLog.Log.WriteWarning(String.Format(Resources.Wsapm_Core.WsapmManager_ValidationErrorCheckInterval, winIdleTimeoutAcMinutes, settings.MonitoringTimerInterval), LogMode.Verbose);
            }

            // Validate if wake timers are allowed.
            if (!WsapmTools.ValidateWakeTimers(settings))
            {
                WsapmLog.Log.WriteWarning(Resources.Wsapm_Core.WsapmManager_ValidationErrorWakeTimers, LogMode.Verbose);
            }
        }
コード例 #3
0
        /// <summary>
        /// Determines if the state of the check interval is valid with the current Windows power options.
        /// </summary>
        /// <param name="settings">The WsampSettings to validate.</param>
        /// <returns>True if the state of the check interval is valid with the current Windows power options, otherwise false.</returns>
        public static bool ValidateCheckInterval(WsapmSettings settings)
        {
            var winIdleTimeoutAcMinutes = WsapmTools.GetCurrentWindowsIdleTimeoutAcMinutes();

            return(!(settings.MonitoringTimerInterval >= winIdleTimeoutAcMinutes));
        }