SystemEvents.PowerModeChanged is not raised on suspend/resume on Surface Pro
- Lingua principale
- C#
- Stelle
- 18.3k
- Fork
- 5.6k
- Metriche di merge delle PR
- Metriche PR in attesa
Descrizione
### 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
Guida per i contributori
Apri la guida per i contributori
Direzione di ricerca
Start by tracing the implementation of SystemEvents.PowerModeChanged and how it handles WM_POWERBROADCAST. Compare that path with PowerRegisterSuspendResumeNotification, then run the provided reproduction on a Surface Pro. Done means the event reports Suspend during sleep and resume without regressing desktop behavior.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- csharp
- Ambito
- desktop, operating-systems
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 38/100