예제 #1
0
        /// <summary>
        /// Creates a new instance of WsapmManager.
        /// </summary>
        public WsapmManager()
        {
            this.settingsManager = new SettingsManager();
            LoadSettings();

            // Create managers.
            this.standbyManager  = new StandbyManager();
            this.wakeManager     = new WakeManager();
            this.pluginManager   = new PluginManager();
            this.shutdownManager = new ShutdownManager();

            this.temporaryUptimeManager = new TemporaryUptimeManager();

            this.lastWakeTime = null;

            this.settingsManager.SettingsChanged += settingsManager_SettingsChanged;
            this.temporaryUptimeManager.TemporaryUptimeChanged += TemporaryUptimeManager_TemporaryUptimeChanged;
        }
예제 #2
0
        /// <summary>
        /// Cleanup of the class.
        /// </summary>
        private void CleanUp()
        {
            try
            {
                StopResumeAutomaticTimer();

                EnableStandby();

                this.standbyManager = null;

                StopShutdownListening();
                this.shutdownManager = null;

                StopMonitoringTimer();
                this.monitoringTimer = null;

                if (this.wakeManager != null)
                {
                    this.wakeManager.WakeTimerCompleted -= wakeManager_WakeTimerCompleted;
                    this.wakeManager.CancelAllWakeTimers();
                }

                this.wakeManager   = null;
                this.pluginManager = null;

                WsapmLog.Log.WriteLine(Resources.Wsapm_Core.WsapmManager_StopMonitoringTimer, LogMode.Normal);

                if (this.settingsManager != null)
                {
                    this.settingsManager.SettingsChanged -= settingsManager_SettingsChanged;
                }

                this.currentSettings = null;
                this.settingsManager = null;
            }
            catch (Exception ex)
            {
                WriteErrorLog(ex);
            }
        }