From 27bc4815771dc21a6bd7bb85156bbe09ff7d4c9d Mon Sep 17 00:00:00 2001 From: GeWuYou <95328647+GeWuYou@users.noreply.github.com> Date: Sat, 24 Jan 2026 15:42:32 +0800 Subject: [PATCH] =?UTF-8?q?feat(Architecture):=20=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E6=9E=B6=E6=9E=84=E5=B0=B1=E7=BB=AA=E7=8A=B6=E6=80=81=E7=AD=89?= =?UTF-8?q?=E5=BE=85=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增 `_readyTcs` 字段用于跟踪架构初始化状态 - 添加 `IsReady` 属性检查当前架构是否已就绪 - 在架构进入 Ready 阶段时释放 Ready await - 实现 `WaitUntilReadyAsync()` 方法支持异步等待架构初始化完成 - [skip ci] --- GFramework.Core/architecture/Architecture.cs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/GFramework.Core/architecture/Architecture.cs b/GFramework.Core/architecture/Architecture.cs index 25ab46a..ba1f269 100644 --- a/GFramework.Core/architecture/Architecture.cs +++ b/GFramework.Core/architecture/Architecture.cs @@ -86,7 +86,9 @@ public abstract class Architecture( #endregion #region Fields + private readonly TaskCompletionSource _readyTcs = new(TaskCreationOptions.RunContinuationsAsynchronously); + public bool IsReady => CurrentPhase == ArchitecturePhase.Ready; /// /// 待初始化组件的去重集合 /// @@ -553,9 +555,18 @@ public abstract class Architecture( _mInitialized = true; EnterPhase(ArchitecturePhase.Ready); - + // 🔥 释放 Ready await + _readyTcs.TrySetResult(); + _logger.Info($"Architecture {GetType().Name} is ready - all components initialized"); } - + + /// + /// 等待架构初始化完成(Ready 阶段) + /// + public Task WaitUntilReadyAsync() + { + return IsReady ? Task.CompletedTask : _readyTcs.Task; + } #endregion } \ No newline at end of file