From 64c85894897c756fe651b3b077d86f29d96ce657 Mon Sep 17 00:00:00 2001 From: gewuyou <95328647+GeWuYou@users.noreply.github.com> Date: Sat, 25 Apr 2026 09:29:01 +0800 Subject: [PATCH] =?UTF-8?q?fix(game):=20=E6=B8=85=E7=90=86=20SettingsSyste?= =?UTF-8?q?m=20=E4=B8=8E=20ScopedStorage=20=E7=9A=84=20MA0004?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 修复 SettingsSystem 中不依赖上下文的 await,补充 ConfigureAwait(false) - 修复 ScopedStorage.DeleteAsync 的 await,保持作用域前缀语义不变 --- GFramework.Game/Setting/SettingsSystem.cs | 10 +++++----- GFramework.Game/Storage/ScopedStorage.cs | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/GFramework.Game/Setting/SettingsSystem.cs b/GFramework.Game/Setting/SettingsSystem.cs index 6b5b2aed..b73580a7 100644 --- a/GFramework.Game/Setting/SettingsSystem.cs +++ b/GFramework.Game/Setting/SettingsSystem.cs @@ -19,7 +19,7 @@ public class SettingsSystem : AbstractSystem, ISettingsSystem public async Task ApplyAll() { // 遍历所有设置应用器并尝试应用 - foreach (var applicator in _model.AllApplicators()) await TryApplyAsync(applicator); + foreach (var applicator in _model.AllApplicators()) await TryApplyAsync(applicator).ConfigureAwait(false); } /// @@ -41,7 +41,7 @@ public class SettingsSystem : AbstractSystem, ISettingsSystem /// 完成的任务 public async Task SaveAll() { - await _model.SaveAllAsync(); + await _model.SaveAllAsync().ConfigureAwait(false); } /// @@ -51,7 +51,7 @@ public class SettingsSystem : AbstractSystem, ISettingsSystem public async Task ResetAll() { _model.ResetAll(); - await ApplyAll(); + await ApplyAll().ConfigureAwait(false); } /// @@ -62,7 +62,7 @@ public class SettingsSystem : AbstractSystem, ISettingsSystem public async Task Reset() where T : class, ISettingsData, IResetApplyAbleSettings, new() { _model.Reset(); - await Apply(); + await Apply().ConfigureAwait(false); } @@ -87,7 +87,7 @@ public class SettingsSystem : AbstractSystem, ISettingsSystem try { - await applyAbleSettings.ApplyAsync(); + await applyAbleSettings.ApplyAsync().ConfigureAwait(false); // 发送设置应用成功事件 this.SendEvent(new SettingsAppliedEvent(section, true)); } diff --git a/GFramework.Game/Storage/ScopedStorage.cs b/GFramework.Game/Storage/ScopedStorage.cs index b0714783..7ab8c856 100644 --- a/GFramework.Game/Storage/ScopedStorage.cs +++ b/GFramework.Game/Storage/ScopedStorage.cs @@ -102,7 +102,7 @@ public sealed class ScopedStorage(IStorage inner, string prefix) : IScopedStorag /// 异步操作任务 public async Task DeleteAsync(string key) { - await inner.DeleteAsync(Key(key)); + await inner.DeleteAsync(Key(key)).ConfigureAwait(false); } /// @@ -166,4 +166,4 @@ public sealed class ScopedStorage(IStorage inner, string prefix) : IScopedStorag { return new ScopedStorage(inner, Key(scope)); } -} \ No newline at end of file +}