From 23eeb8ff55c8e6edae0b9810f053751b46fa4214 Mon Sep 17 00:00:00 2001 From: 2dust <31833384+2dust@users.noreply.github.com> Date: Fri, 18 Apr 2025 12:31:46 +0800 Subject: [PATCH] Try to fix https://github.com/2dust/v2rayN/issues/7128 --- v2rayN/ServiceLib/ViewModels/MainWindowViewModel.cs | 7 +++++-- v2rayN/ServiceLib/ViewModels/StatusBarViewModel.cs | 5 ++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/v2rayN/ServiceLib/ViewModels/MainWindowViewModel.cs b/v2rayN/ServiceLib/ViewModels/MainWindowViewModel.cs index ec07b825..5edab5d4 100644 --- a/v2rayN/ServiceLib/ViewModels/MainWindowViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/MainWindowViewModel.cs @@ -548,8 +548,11 @@ public class MainWindowViewModel : MyReactiveObject BlReloadEnabled = false; - await LoadCore(); - await SysProxyHandler.UpdateSysProxy(_config, false); + await Task.Run(async () => + { + await LoadCore(); + await SysProxyHandler.UpdateSysProxy(_config, false); + }); Locator.Current.GetService()?.TestServerAvailability(); _updateView?.Invoke(EViewAction.DispatcherReload, null); diff --git a/v2rayN/ServiceLib/ViewModels/StatusBarViewModel.cs b/v2rayN/ServiceLib/ViewModels/StatusBarViewModel.cs index 4c7a5c1c..00cc391a 100644 --- a/v2rayN/ServiceLib/ViewModels/StatusBarViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/StatusBarViewModel.cs @@ -318,7 +318,10 @@ public class StatusBarViewModel : MyReactiveObject _updateView?.Invoke(EViewAction.DispatcherServerAvailability, ResUI.Speedtesting); - var msg = await (new UpdateService()).RunAvailabilityCheck(); + var msg = await Task.Run(async () => + { + return await (new UpdateService()).RunAvailabilityCheck(); + }); NoticeHandler.Instance.SendMessageEx(msg); _updateView?.Invoke(EViewAction.DispatcherServerAvailability, msg);