I have this simple app for detecting sleep/resume events of my laptop:
using Microsoft.Win32;
using System;
namespace ConsoleApp2
{
internal class Program
{
static void Main(string[] args)
{
SystemEvents.PowerModeChanged +=
new PowerModeChangedEventHandler(SystemEvents_PowerModeChanged);
Console.ReadLine();
}
static void SystemEvents_PowerModeChanged(object sender, PowerModeChangedEventArgs e)
{
Console.WriteLine(e.Mode);
}
}
}
When I plug/unplug power lead I can see the message StatusChange on the console but If I press sleep button and resume laptop later then nothing is printed on the console.
For some reason sleep/resume events does not reach to the app. Can you hint how to fix it ?