ObjectSharp Blogs

You are currently viewing

Dave Lloyd's 2 Cents

A .NET Developer's Perspective


PowerStatus

The project I am working on right now is a software factory that will eventually allow it's users to build software that controls robots and other devices in a laboratory.

Today I wrote a service that monitors the power on the machine it's running. The idea is the service will raise an event if the machine loses power, and will then monitor the remaining life of the UPS. This will allow the system to save any data to disk before the UPS gives up the ghost.

To write this I used a class that is new to .NET 2.0 called PowerStatus. This is a very useful little class.

First of all you can check various useful properties relating to your machines power supply.

Also you can handle the PowerLineStatusChanged event which will fire when the Power State changes.  In this event you can tell if the Power is connected or not and if the computer is about to resume or suspend.

There is a great code example and sample application here

 

Comments

    No Comments

Leave a Comment

(required) 
(optional)
(required) 

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS