Challenge
Monitor the power mode to detect when the user suspends or resumes the system. Intel's mobile processors utilize advanced power-management technologies to take advantage of idle time to save power. For example, QuickStart is a feature that allows a CPU to resume rapidly from a low-power state. Thus, a CPU can quickly enter and exit low-power states between keystrokes. Although these idle times are brief, they enable laptop machines to reduce power consumption significantly.
Another major feature of Intel mobile processors is Intel® SpeedStep® technology, which automatically detects whether the mobile PC is using battery or AC power. When using battery power, Intel SpeedStep technology scales the processor clock frequency and voltage to reduce power needs.
ACPI (Advanced Configuration and Power Interface)* is an open industry standard for power management on laptops, desktops, and servers. Co-developed by Intel, Microsoft, Hewlett-Packard, and Toshiba, ACPI enables intelligent power management and consumption by turning on devices only when they are needed and controlling the speed of the processor depending on application requirements. Thus, ACPI helps conserve battery life, enabling powerful applications to run on mobile platforms without unduly draining battery resources.
Solution
Use the .NET PowerModeChanged event. The .NET Framework class library provides support for applications to monitor power status using the PowerModeChanged event. The PowerModeChanged event fires whenever a user suspends or resumes the system. To use the PowerModeChanged event, first wire up an event handler:
SystemEvents.PowerModeChanged += new PowerModeChangedEventHandler (SystemEvents_PowerModeChanged); |
Then create the event handler itself:
|
The Mode property of the PowerModeChangedEventArgs class is an enumerated constant with the following values:
- Resume - Indicates that the operating system is about to resume.
- StatusChange - Indicates that the power mode status of the operating system has changed. This can be a transition from battery to AC power, a weak or charging battery, or other change in the power status.
- Suspend - Indicates that the operating system is about to be suspended.
For example, in Windows* XP, selecting the Start | Turn Off Computer | Stand By menu command triggers a Suspend event. Resuming will result in a Resume event.
Source
Mobile Reference Model: Power Management and Mobilized Software Initiatives
