SystemEvents.PowerModeChanged is not raised on suspend/resume on Surface Pro
- Dominant language
- C#
- Stars
- 18.3k
- Forks
- 5.6k
- PR merge metrics
- PR metrics pending
Description
### Description
When Surface Pro sleeps, the [SystemEvents.PowerModeChanged](https://learn.microsoft.com/en-us/dotnet/api/microsoft.win32.systemevents.powermodechanged) event is not raised
### Reproduction Steps
`SystemEvents.PowerModeChanged += (s, e) => Debug.WriteLine(e.Mode);`
### Expected behavior
Should print `Suspend` on Sleep
### Actual behavior
Prints 'Suspend' on Desktop
No output on Surface Pro
### Regression?
_No response_
### Known Workarounds
Use `PowerRegisterSuspendResumeNotification`
### Configuration
dotnet SDK 10.0.102
Windows 11 (10.0.26200)
x64
### Other information
WM_POWERBROADCAST doesn't work for laptops
https://learn.microsoft.com/en-us/windows/win32/power/wm-powerbroadcast
PowerRegisterSuspendResumeNotification is available on Windows 8+ which works as expected:
https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-registersuspendresumenotification
Contributor guide
Assessment
This issue has not been assessed yet.