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
|
#endregion Menu
|
||||||
|
|
||||||
|
private bool _hasNextReloadJob = false;
|
||||||
|
|
||||||
#region Init
|
#region Init
|
||||||
|
|
||||||
public MainWindowViewModel(Func<EViewAction, object?, Task<bool>>? updateView)
|
public MainWindowViewModel(Func<EViewAction, object?, Task<bool>>? updateView)
|
||||||
|
|
@ -266,6 +268,7 @@ public class MainWindowViewModel : MyReactiveObject
|
||||||
}
|
}
|
||||||
await RefreshServers();
|
await RefreshServers();
|
||||||
|
|
||||||
|
SetReloadEnabled(true);
|
||||||
await Reload();
|
await Reload();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -522,20 +525,15 @@ public class MainWindowViewModel : MyReactiveObject
|
||||||
|
|
||||||
#region core job
|
#region core job
|
||||||
|
|
||||||
private bool _hasNextReloadJob = false;
|
|
||||||
private readonly SemaphoreSlim _reloadSemaphore = new(1, 1);
|
|
||||||
|
|
||||||
public async Task Reload()
|
public async Task Reload()
|
||||||
{
|
{
|
||||||
//If there are unfinished reload job, marked with next job.
|
//If there are unfinished reload job, marked with next job.
|
||||||
if (!await _reloadSemaphore.WaitAsync(0))
|
if (!BlReloadEnabled)
|
||||||
{
|
{
|
||||||
_hasNextReloadJob = true;
|
_hasNextReloadJob = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
SetReloadEnabled(false);
|
SetReloadEnabled(false);
|
||||||
|
|
||||||
var msgs = await ActionPrecheckManager.Instance.Check(_config.IndexId);
|
var msgs = await ActionPrecheckManager.Instance.Check(_config.IndexId);
|
||||||
|
|
@ -546,6 +544,7 @@ public class MainWindowViewModel : MyReactiveObject
|
||||||
NoticeManager.Instance.SendMessage(msg);
|
NoticeManager.Instance.SendMessage(msg);
|
||||||
}
|
}
|
||||||
NoticeManager.Instance.Enqueue(Utils.List2String(msgs.Take(10).ToList(), true));
|
NoticeManager.Instance.Enqueue(Utils.List2String(msgs.Take(10).ToList(), true));
|
||||||
|
SetReloadEnabled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -564,19 +563,13 @@ public class MainWindowViewModel : MyReactiveObject
|
||||||
}
|
}
|
||||||
|
|
||||||
ReloadResult(showClashUI);
|
ReloadResult(showClashUI);
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
SetReloadEnabled(true);
|
SetReloadEnabled(true);
|
||||||
_reloadSemaphore.Release();
|
|
||||||
//If there is a next reload job, execute it.
|
|
||||||
if (_hasNextReloadJob)
|
if (_hasNextReloadJob)
|
||||||
{
|
{
|
||||||
_hasNextReloadJob = false;
|
_hasNextReloadJob = false;
|
||||||
await Reload();
|
await Reload();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private void ReloadResult(bool showClashUI)
|
private void ReloadResult(bool showClashUI)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue