protected override bool OnPowerEvent(PowerBroadcastStatus powerStatus) { SystemEvents.PowerModeChanged += new PowerModeChangedEventHandler((s, e) => { switch (e.Mode) { case PowerModes.Suspend: break; case PowerModes.Resume: break; } }); switch (powerStatus) { case PowerBroadcastStatus.Suspend: _numMonitors = 0; Logging.LogEvents("Sleep"); _sleeping = true; break; case PowerBroadcastStatus.ResumeSuspend: _numMonitors = SystemStats.GetNumMonitors(); Logging.LogEvents("Wake"); _sleeping = false; break; } return(base.OnPowerEvent(powerStatus)); }
private void Update() { _numMonitors = SystemStats.GetNumMonitors(); var energy = CorrectEnergyError(SystemStats.GetPowerUsageSinceLastQuery()); _joulesTotal += energy.joules + GetMonitorJoulesUsed(_numMonitors); WriteData(energy); }
protected override void OnSessionChange(SessionChangeDescription changeDescription) { switch (changeDescription.Reason) { case SessionChangeReason.SessionLock: _numMonitors = 0; Logging.LogEvents("Locked"); _locked = true; break; case SessionChangeReason.SessionUnlock: _numMonitors = SystemStats.GetNumMonitors(); Logging.LogEvents("Unlocked"); _locked = false; break; } }