Skip to content

Commit 32583ea

Browse files
committed
Bug fix
Replaced direct assignments to BlReloadEnabled with a new SetReloadEnabled method that schedules updates on the main thread.
1 parent 69797c1 commit 32583ea

1 file changed

Lines changed: 15 additions & 9 deletions

File tree

v2rayN/ServiceLib/ViewModels/MainWindowViewModel.cs

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ private async Task Init()
268268
}
269269
await RefreshServers();
270270

271-
BlReloadEnabled = true;
271+
SetReloadEnabled(true);
272272
await Reload();
273273
}
274274

@@ -534,7 +534,7 @@ public async Task Reload()
534534
return;
535535
}
536536

537-
BlReloadEnabled = false;
537+
SetReloadEnabled(false);
538538

539539
var msgs = await ActionPrecheckManager.Instance.Check(_config.IndexId);
540540
if (msgs.Count > 0)
@@ -544,7 +544,7 @@ public async Task Reload()
544544
NoticeManager.Instance.SendMessage(msg);
545545
}
546546
NoticeManager.Instance.Enqueue(Utils.List2String(msgs.Take(10).ToList(), true));
547-
BlReloadEnabled = true;
547+
SetReloadEnabled(true);
548548
return;
549549
}
550550

@@ -562,9 +562,8 @@ await Task.Run(async () =>
562562
AppEvents.ProxiesReloadRequested.Publish();
563563
}
564564

565-
RxApp.MainThreadScheduler.Schedule(() => ReloadResult(showClashUI));
566-
567-
BlReloadEnabled = true;
565+
ReloadResult(showClashUI);
566+
SetReloadEnabled(true);
568567
if (_hasNextReloadJob)
569568
{
570569
_hasNextReloadJob = false;
@@ -574,9 +573,16 @@ await Task.Run(async () =>
574573

575574
private void ReloadResult(bool showClashUI)
576575
{
577-
// BlReloadEnabled = true;
578-
ShowClashUI = showClashUI;
579-
TabMainSelectedIndex = showClashUI ? TabMainSelectedIndex : 0;
576+
RxApp.MainThreadScheduler.Schedule(() =>
577+
{
578+
ShowClashUI = showClashUI;
579+
TabMainSelectedIndex = showClashUI ? TabMainSelectedIndex : 0;
580+
});
581+
}
582+
583+
private void SetReloadEnabled(bool enabled)
584+
{
585+
RxApp.MainThreadScheduler.Schedule(() => BlReloadEnabled = enabled);
580586
}
581587

582588
private async Task LoadCore()

0 commit comments

Comments
 (0)