/// <summary> /// Puts the system into sleep mode (Suspend/Hibernate) /// </summary> /// <param name="source">Description of who wants to suspend the system</param> /// <param name="how">How to suspend, see MediaPortal.Util.RestartOptions</param> /// <param name="force">Force the system to suspend (XP only)</param> public void SuspendSystem(string source, int how, bool force) { Log.Debug("PS: SuspendSystem(source: {0}, how: {1}, force: {2})", source, (RestartOptions)how, force); if (_standby) { Log.Debug("PS: SuspendSystem aborted - suspend request is already in progress"); return; } Log.Debug("PS: Kick off shutdown thread (how: {0})", (RestartOptions)how); SuspendSystemThreadEnv data = new SuspendSystemThreadEnv(); data.that = this; data.how = (RestartOptions)how; data.force = force; data.source = source; Thread _suspendThread = new Thread(SuspendSystemThread); _suspendThread.Name = "PS Suspend"; _suspendThread.Start(data); }
/// <summary> /// Puts the system into the configured standby mode (Suspend/Hibernate) /// </summary> /// <param name="force">should the system be forced to enter standby?</param> /// <returns>bool indicating whether or not the request was honoured</returns> public void SuspendSystem(string source, int how, bool force) { lock (this) { DateTime now = DateTime.Now; // block concurrent request? if (_ignoreSuspendUntil > now) { Log.Info("PowerScheduler: Concurrent shutdown was ignored: {0} ; force: {1}", (RestartOptions)how, force); return; } // block any other request forever (for now) _ignoreSuspendUntil = DateTime.MaxValue; } Log.Info("PowerScheduler: Entering shutdown {0} ; forced: {1} -- kick off shutdown thread", (RestartOptions)how, force); SuspendSystemThreadEnv data = new SuspendSystemThreadEnv(); data.that = this; data.how = (RestartOptions)how; data.force = force; data.source = source; Thread suspendThread = new Thread(SuspendSystemThread); suspendThread.Name = "Powerscheduler Suspender"; suspendThread.Start(data); }