mirror of
https://github.com/2dust/v2rayN.git
synced 2025-11-29 03:02:53 +00:00
Compare commits
No commits in common. "e20c11c1a7a0759771df87bfec1fe0d9c6a3ae93" and "6f06b16c76d529faec9a49dd5881bf8635ca5c60" have entirely different histories.
e20c11c1a7
...
6f06b16c76
1 changed files with 34 additions and 41 deletions
|
|
@ -64,6 +64,8 @@ public class MainWindowViewModel : MyReactiveObject
|
|||
|
||||
#endregion Menu
|
||||
|
||||
private bool _hasNextReloadJob = false;
|
||||
|
||||
#region Init
|
||||
|
||||
public MainWindowViewModel(Func<EViewAction, object?, Task<bool>>? updateView)
|
||||
|
|
@ -266,6 +268,7 @@ public class MainWindowViewModel : MyReactiveObject
|
|||
}
|
||||
await RefreshServers();
|
||||
|
||||
SetReloadEnabled(true);
|
||||
await Reload();
|
||||
}
|
||||
|
||||
|
|
@ -522,20 +525,15 @@ public class MainWindowViewModel : MyReactiveObject
|
|||
|
||||
#region core job
|
||||
|
||||
private bool _hasNextReloadJob = false;
|
||||
private readonly SemaphoreSlim _reloadSemaphore = new(1, 1);
|
||||
|
||||
public async Task Reload()
|
||||
{
|
||||
//If there are unfinished reload job, marked with next job.
|
||||
if (!await _reloadSemaphore.WaitAsync(0))
|
||||
if (!BlReloadEnabled)
|
||||
{
|
||||
_hasNextReloadJob = true;
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
SetReloadEnabled(false);
|
||||
|
||||
var msgs = await ActionPrecheckManager.Instance.Check(_config.IndexId);
|
||||
|
|
@ -546,6 +544,7 @@ public class MainWindowViewModel : MyReactiveObject
|
|||
NoticeManager.Instance.SendMessage(msg);
|
||||
}
|
||||
NoticeManager.Instance.Enqueue(Utils.List2String(msgs.Take(10).ToList(), true));
|
||||
SetReloadEnabled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -564,19 +563,13 @@ public class MainWindowViewModel : MyReactiveObject
|
|||
}
|
||||
|
||||
ReloadResult(showClashUI);
|
||||
}
|
||||
finally
|
||||
{
|
||||
SetReloadEnabled(true);
|
||||
_reloadSemaphore.Release();
|
||||
//If there is a next reload job, execute it.
|
||||
if (_hasNextReloadJob)
|
||||
{
|
||||
_hasNextReloadJob = false;
|
||||
await Reload();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ReloadResult(bool showClashUI)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue