public WindowsDeviceLocking() { SystemEvents.SessionEnding += SystemEvents_SessionEnding; SystemEvents.SessionSwitch += SystemEvents_SessionSwitch; SystemEvents.PowerModeChanged += SystemEvents_PowerModeChanged; _timer.SetInterval(TimeSpan.FromSeconds(2)); _timer.Elapsed += PollScreenSaverState; }
/// <summary> /// Create an instance bound to an action delegate and a minimum idle time. /// </summary> /// <param name="minimumIdleTime">The minium time of idle before actually performing the action.</param> public DelayedAction(IDelayTimer timer, TimeSpan minimumIdleTime) { if (timer == null) { throw new ArgumentNullException("timer"); } _timer = timer; _timer.SetInterval(minimumIdleTime); _timer.Elapsed += HandleTimerElapsedEvent; }