Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

detect power state change

Tags:

c#

What is the best way to detect when Windows power state is changing?

I need to preform some actions depending on whether the computer is going to Standby/Hibernate/Shut Down

like image 703
Steven Avatar asked Dec 29 '22 06:12

Steven


1 Answers

The SystemEvents.PowerModeChanged event should do what you want

You might also want to check out the SystemInformation.PowerStatus property.

like image 186
Thomas Levesque Avatar answered Jan 12 '23 05:01

Thomas Levesque