mirror of https://github.com/2dust/v2rayN
Improve reload function
parent
7370684985
commit
4ad4e27dc1
|
@ -63,6 +63,8 @@ namespace ServiceLib.ViewModels
|
||||||
|
|
||||||
#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)
|
||||||
|
@ -534,14 +536,12 @@ namespace ServiceLib.ViewModels
|
||||||
|
|
||||||
#region core job
|
#region core job
|
||||||
|
|
||||||
public async Task Reload(int times = 0)
|
public async Task Reload()
|
||||||
{
|
{
|
||||||
//If there are unfinished reload job, wait a few seconds and exec again.
|
//If there are unfinished reload job, marked with next job.
|
||||||
if (!BlReloadEnabled)
|
if (!BlReloadEnabled)
|
||||||
{
|
{
|
||||||
await Task.Delay(3000);
|
_hasNextReloadJob = true;
|
||||||
if (times > 3) return;
|
|
||||||
await Reload(++times);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -552,12 +552,19 @@ namespace ServiceLib.ViewModels
|
||||||
await SysProxyHandler.UpdateSysProxy(_config, false);
|
await SysProxyHandler.UpdateSysProxy(_config, false);
|
||||||
|
|
||||||
_updateView?.Invoke(EViewAction.DispatcherReload, null);
|
_updateView?.Invoke(EViewAction.DispatcherReload, null);
|
||||||
|
|
||||||
|
BlReloadEnabled = true;
|
||||||
|
if (_hasNextReloadJob)
|
||||||
|
{
|
||||||
|
_hasNextReloadJob = false;
|
||||||
|
await Reload();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ReloadResult()
|
public void ReloadResult()
|
||||||
{
|
{
|
||||||
|
// BlReloadEnabled = true;
|
||||||
//Locator.Current.GetService<StatusBarViewModel>()?.ChangeSystemProxyAsync(_config.systemProxyItem.sysProxyType, false);
|
//Locator.Current.GetService<StatusBarViewModel>()?.ChangeSystemProxyAsync(_config.systemProxyItem.sysProxyType, false);
|
||||||
BlReloadEnabled = true;
|
|
||||||
ShowClashUI = _config.IsRunningCore(ECoreType.sing_box);
|
ShowClashUI = _config.IsRunningCore(ECoreType.sing_box);
|
||||||
if (ShowClashUI)
|
if (ShowClashUI)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue