I want to make my program aware of the computer being put to sleep or waking up from sleep, possibly have an event that is triggered when either of these occur. Is this possible?
You can subscribe to the SystemEvents.PowerModeChanged event.
SystemEvents.PowerModeChanged += OnPowerChange; void OnPowerChange(Object sender, PowerModeChangedEventArgs e) { switch ( e.Mode ) { case PowerModes.Resume: ... case PowerModes.Suspend: ... } }
1.4m articles
1.4m replys
5 comments
57.0k users