--- title: "Power Management" ms.date: "03/30/2017" dev_langs: - "csharp" - "vb" helpviewer_keywords: - "battery states" - "power states" ms.assetid: ad04a801-5682-4d88-92c5-26eb9cdb209a --- # Power Management in Windows Forms Your Windows Forms applications can take advantage of the power management features in the Windows operating system. Your applications can monitor the power status of a computer and take action when a status change occurs. For example, if your application is running on a portable computer, you might want to disable certain features in your application when the computer's battery charge falls under a certain level. The .NET Framework provides a event that occurs whenever there is a change in power status, such as when a user suspends or resumes the operating system, or when the AC power status or battery status changes. The property of the class can be used to query for the current status, as shown in the following code example. [!code-csharp[PowerMode#1](~/samples/snippets/csharp/VS_Snippets_Winforms/powermode/cs/form1.cs#1)] [!code-vb[PowerMode#1](~/samples/snippets/visualbasic/VS_Snippets_Winforms/powermode/vb/form1.vb#1)] Besides the enumerations, the property also contains enumerations for determining battery capacity () and battery charge percentage (, ). You can use the method of the to put a computer into hibernation or suspend mode. If the `force` argument is set to `false`, the operating system will broadcast an event to all applications requesting permission to suspend. If the `disableWakeEvent` argument is set to `true`, the operating system disables all wake events. The following code example demonstrates how to put a computer into hibernation. [!code-csharp[PowerMode#2](~/samples/snippets/csharp/VS_Snippets_Winforms/powermode/cs/form1.cs#2)] [!code-vb[PowerMode#2](~/samples/snippets/visualbasic/VS_Snippets_Winforms/powermode/vb/form1.vb#2)] ## See also - - - -