dotnet / dotnet/runtime

SystemEvents.PowerModeChanged is not raised on suspend/resume on Surface Pro

オープン
#123,773 コメント 3 件 リアクション 0 件 担当者 0 名 GitHub で見る
area-Microsoft.Win32 bug help wanted
主要言語
C#
スター
18.3k
フォーク
5.6k
PR マージ指標
PR 指標を取得中

説明

### 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

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

まず、SystemEvents.PowerModeChanged の実装と、WM_POWERBROADCAST の処理方法を追跡します。その経路を PowerRegisterSuspendResumeNotification と比較し、続いて提供された再現手順を Surface Pro で実行します。スリープ中と復帰時にイベントが Suspend を報告し、デスクトップでの動作を後退させないことを確認できれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
csharp
領域
desktop, operating-systems
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
38/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。