The Windows operating system provides a comprehensive, system-wide set of power-management features. This enables systems to extend battery life and save energy, reduce heat and noise and help ensure data reliability.

The power-management functions and messages retrieve the system power status, notify applications of power-management events and notify the system of each application’s power requirements.

PowerState represents the state of the current power system, such as:

  • The presence of a battery
  • The state of the battery
  • Whether or not the system is charging

Also, if you subscribe to the Announcements of the class, you will receive announcements regarding events for major state changes, such as when the battery is low, etc.  You will also receive announcements when the operating system changes to sleep, hibernate and shut down and also when operation is resumed after a sleep or hibernate.

Using these announcements, you can save the image, disconnect from the database or do other cleanup before the system goes to sleep. When the system resumes, you can reconnect to the database or open a login dialog.

The BatteryMeter is just a small sample that shows the properties of the new class “PowerState.”

Advertisements