From 85c2c1638e2c852de0eee2be9e54222bf1d5f0ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A3=B9=E7=9F=B3=E5=9B=9B?= Date: Mon, 24 Nov 2025 18:47:43 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E6=9C=89=E6=A6=82=E7=8E=87=E5=9C=A8?= =?UTF-8?q?=E9=80=80=E5=87=BA=E7=9A=84=E6=97=B6=E5=80=99=E5=BC=B9=E9=94=99?= =?UTF-8?q?=E8=AF=AF=E5=BC=B9=E7=AA=97=20(#1928)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Plain Craft Launcher 2/Modules/Base/ModBase.vb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Plain Craft Launcher 2/Modules/Base/ModBase.vb b/Plain Craft Launcher 2/Modules/Base/ModBase.vb index 08735423..a1248b17 100644 --- a/Plain Craft Launcher 2/Modules/Base/ModBase.vb +++ b/Plain Craft Launcher 2/Modules/Base/ModBase.vb @@ -2211,6 +2211,7 @@ NextElement: ''' 为防止线程互锁,请仅在开始加载动画、从 UI 获取输入时使用! ''' Public Sub RunInUiWait(Action As Action) + If Application.Current Is Nothing Then Exit Sub If RunInUi() Then Action() Else @@ -2222,12 +2223,11 @@ NextElement: ''' 如果当前并非 UI 线程,也不阻断当前线程的执行。 ''' Public Sub RunInUi(Action As Action, Optional ForceWaitUntilLoaded As Boolean = False) - If ForceWaitUntilLoaded Then - Application.Current.Dispatcher.InvokeAsync(Action, Threading.DispatcherPriority.Loaded) - ElseIf RunInUi() Then + If Application.Current Is Nothing Then Exit Sub + If RunInUi() Then Action() Else - Application.Current.Dispatcher.InvokeAsync(Action) + Application.Current.Dispatcher.InvokeAsync(Action, If(ForceWaitUntilLoaded, Threading.DispatcherPriority.Loaded, Threading.DispatcherPriority.Normal)) End If End Sub '''