Improvements and Adjustments

await Task.CompletedTask;
return await Task.FromResult(0);
pull/6513/head
2dust 2025-01-15 17:26:15 +08:00
parent 77b15cd530
commit f1601c463b
23 changed files with 64 additions and 42 deletions

View File

@ -135,7 +135,7 @@
return await SQLiteHelper.Instance.TableAsync<SubItem>().OrderBy(t => t.Sort).ToListAsync();
}
public async Task<SubItem?> GetSubItem(string subid)
public async Task<SubItem?> GetSubItem(string? subid)
{
return await SQLiteHelper.Instance.TableAsync<SubItem>().FirstOrDefaultAsync(t => t.Id == subid);
}

View File

@ -45,6 +45,8 @@ namespace ServiceLib.Handler
{
AutoStartTaskService(autoRunName, "", "");
}
await Task.CompletedTask;
}
private static async Task SetTaskWindows()
@ -66,6 +68,7 @@ namespace ServiceLib.Handler
{
Logging.SaveLog(_tag, ex);
}
await Task.CompletedTask;
}
/// <summary>
@ -127,6 +130,7 @@ namespace ServiceLib.Handler
{
Logging.SaveLog(_tag, ex);
}
await Task.CompletedTask;
}
private static async Task SetTaskLinux()

View File

@ -162,7 +162,7 @@ namespace ServiceLib.Handler
Length = "100-200",
Interval = "10-20"
};
if (config.SystemProxyItem.SystemProxyExceptions.IsNullOrEmpty())
{
config.SystemProxyItem.SystemProxyExceptions = Utils.IsWindows() ? Global.SystemProxyExceptionsWindows : Global.SystemProxyExceptionsLinux;
@ -472,7 +472,7 @@ namespace ServiceLib.Handler
}
ProfileExHandler.Instance.SetSort(lstProfile[index].IndexId, sort);
return 0;
return await Task.FromResult(0);
}
/// <summary>
@ -1050,7 +1050,7 @@ namespace ServiceLib.Handler
Port = node.PreSocksPort.Value,
};
}
await Task.CompletedTask;
return itemSocks;
}
@ -1620,7 +1620,7 @@ namespace ServiceLib.Handler
break;
}
}
return 0;
return await Task.FromResult(0);
}
public static async Task<int> SetDefaultRouting(Config config, RoutingItem routingItem)

View File

@ -80,7 +80,7 @@
ret.Msg = string.Format(ResUI.SuccessfulConfiguration, "");
ret.Success = true;
return ret;
return await Task.FromResult(ret);
}
catch (Exception ex)
{

View File

@ -20,7 +20,7 @@ namespace ServiceLib.Handler
public async Task Init()
{
await InitData();
Task.Run(async () =>
_ = Task.Run(async () =>
{
while (true)
{
@ -32,7 +32,7 @@ namespace ServiceLib.Handler
public async Task<ConcurrentBag<ProfileExItem>> GetProfileExs()
{
return _lstProfileEx;
return await Task.FromResult(_lstProfileEx);
}
private async Task InitData()

View File

@ -72,7 +72,7 @@
return;
}
if(indexId == toIndexId)
if (indexId == toIndexId)
{
return;
}
@ -101,7 +101,7 @@
private void UpdateServerStatHandler(ServerSpeedItem server)
{
UpdateServerStat(server);
_ = UpdateServerStat(server);
}
private async Task UpdateServerStat(ServerSpeedItem server)

View File

@ -29,7 +29,7 @@
public string? destinationPort { get; set; }
public string? host { get; set; }
public string? nsMode { get; set; }
public object uid { get; set; }
public object? uid { get; set; }
public string? process { get; set; }
public string? processPath { get; set; }
public string? remoteDestination { get; set; }

View File

@ -476,7 +476,7 @@ namespace ServiceLib.Services.CoreConfig
{
Logging.SaveLog(_tag, ex);
}
return 0;
return await Task.FromResult(0);
}
private async Task<int> GenInbounds(SingboxConfig singboxConfig)
@ -721,7 +721,7 @@ namespace ServiceLib.Services.CoreConfig
{
Logging.SaveLog(_tag, ex);
}
return 0;
return await Task.FromResult(0);
}
private async Task<int> GenOutboundTls(ProfileItem node, Outbound4Sbox outbound)
@ -771,7 +771,7 @@ namespace ServiceLib.Services.CoreConfig
{
Logging.SaveLog(_tag, ex);
}
return 0;
return await Task.FromResult(0);
}
private async Task<int> GenOutboundTransport(ProfileItem node, Outbound4Sbox outbound)
@ -848,7 +848,7 @@ namespace ServiceLib.Services.CoreConfig
{
Logging.SaveLog(_tag, ex);
}
return 0;
return await Task.FromResult(0);
}
private async Task<int> GenMoreOutbounds(ProfileItem node, SingboxConfig singboxConfig)
@ -1088,7 +1088,7 @@ namespace ServiceLib.Services.CoreConfig
{
Logging.SaveLog(_tag, ex);
}
return 0;
return await Task.FromResult(0);
}
private bool ParseV2Domain(string domain, Rule4Sbox rule)
@ -1240,7 +1240,7 @@ namespace ServiceLib.Services.CoreConfig
}
singboxConfig.dns = dns4Sbox;
return 0;
return await Task.FromResult(0);
}
private async Task<int> GenExperimental(SingboxConfig singboxConfig)
@ -1264,7 +1264,7 @@ namespace ServiceLib.Services.CoreConfig
};
}
return 0;
return await Task.FromResult(0);
}
private async Task<int> ConvertGeo2Ruleset(SingboxConfig singboxConfig)

View File

@ -379,7 +379,7 @@ namespace ServiceLib.Services.CoreConfig
{
Logging.SaveLog(_tag, ex);
}
return 0;
return await Task.FromResult(0);
}
private async Task<int> GenInbounds(V2rayConfig v2rayConfig)
@ -423,7 +423,7 @@ namespace ServiceLib.Services.CoreConfig
{
Logging.SaveLog(_tag, ex);
}
return 0;
return await Task.FromResult(0);
}
private Inbounds4Ray GetInbound(InItem inItem, EInboundProtocol protocol, bool bSocks)
@ -560,7 +560,7 @@ namespace ServiceLib.Services.CoreConfig
{
Logging.SaveLog(_tag, ex);
}
return 0;
return await Task.FromResult(0);
}
private async Task<int> GenOutbound(ProfileItem node, Outbounds4Ray outbound)
@ -774,7 +774,7 @@ namespace ServiceLib.Services.CoreConfig
{
Logging.SaveLog(_tag, ex);
}
return 0;
return await Task.FromResult(0);
}
private async Task<int> GenBoundStreamSettings(ProfileItem node, Outbounds4Ray outbound)
@ -1103,7 +1103,7 @@ namespace ServiceLib.Services.CoreConfig
servers.AsArray().Add(JsonUtils.SerializeToNode(dnsServer));
}
}
return 0;
return await Task.FromResult(0);
}
private async Task<int> GenStatistic(V2rayConfig v2rayConfig)
@ -1150,7 +1150,7 @@ namespace ServiceLib.Services.CoreConfig
v2rayConfig.routing.rules.Add(apiRoutingRule);
}
}
return 0;
return await Task.FromResult(0);
}
private async Task<int> GenMoreOutbounds(ProfileItem node, V2rayConfig v2rayConfig)

View File

@ -25,6 +25,7 @@ namespace ServiceLib.ViewModels
BrowseServerCmd = ReactiveCommand.CreateFromTask(async () =>
{
_updateView?.Invoke(EViewAction.BrowseServer, null);
await Task.CompletedTask;
});
EditServerCmd = ReactiveCommand.CreateFromTask(async () =>
{
@ -109,6 +110,7 @@ namespace ServiceLib.ViewModels
{
NoticeHandler.Instance.Enqueue(ResUI.FailedReadConfiguration);
}
await Task.CompletedTask;
}
}
}

View File

@ -176,7 +176,7 @@ namespace ServiceLib.ViewModels
FileManager.CopyDirectory(configDir, configDirTemp, false, "cache.db");
var ret = FileManager.CreateFromDirectory(configDirZipTemp, fileName);
Directory.Delete(configDirZipTemp, true);
return ret;
return await Task.FromResult(ret);
}
}
}

View File

@ -48,7 +48,7 @@ namespace ServiceLib.ViewModels
await ClashConnectionClose(true);
});
Init();
_ = Init();
}
private async Task Init()
@ -73,6 +73,7 @@ namespace ServiceLib.ViewModels
Task.Delay(1000).Wait();
}
});
await Task.CompletedTask;
}
private async Task GetClashConnections()

View File

@ -90,13 +90,13 @@ namespace ServiceLib.ViewModels
y => y == true)
.Subscribe(c => { _config.ClashUIItem.ProxiesAutoRefresh = AutoRefresh; });
Init();
_ = Init();
}
private async Task Init()
{
await ProxiesReload();
DelayTestTask();
_ = DelayTestTask();
}
private async Task DoRulemodeSelected(bool c)
@ -265,7 +265,7 @@ namespace ServiceLib.ViewModels
return;
}
_proxies.TryGetValue(name, out ProxiesItem proxy);
_proxies.TryGetValue(name, out var proxy);
if (proxy == null || proxy.all == null)
{
return;
@ -316,7 +316,7 @@ namespace ServiceLib.ViewModels
{
if (_proxies is null)
return null;
_proxies.TryGetValue(name, out ProxiesItem proxy2);
_proxies.TryGetValue(name, out var proxy2);
if (proxy2 != null)
{
return proxy2;
@ -399,6 +399,7 @@ namespace ServiceLib.ViewModels
_updateView?.Invoke(EViewAction.DispatcherProxiesDelayTest, new SpeedTestResult() { IndexId = item.Name, Delay = result });
});
await Task.CompletedTask;
}
public void ProxiesDelayTestResult(SpeedTestResult result)
@ -434,7 +435,7 @@ namespace ServiceLib.ViewModels
public async Task DelayTestTask()
{
var lastTime = DateTime.Now;
Task.Run(async () =>
_ = Task.Run(async () =>
{
while (true)
{
@ -457,6 +458,7 @@ namespace ServiceLib.ViewModels
lastTime = dtNow;
}
});
await Task.CompletedTask;
}
#endregion task

View File

@ -32,15 +32,17 @@ namespace ServiceLib.ViewModels
ImportDefConfig4V2rayCmd = ReactiveCommand.CreateFromTask(async () =>
{
normalDNS = Utils.GetEmbedText(Global.DNSV2rayNormalFileName);
await Task.CompletedTask;
});
ImportDefConfig4SingboxCmd = ReactiveCommand.CreateFromTask(async () =>
{
normalDNS2 = Utils.GetEmbedText(Global.DNSSingboxNormalFileName);
tunDNS2 = Utils.GetEmbedText(Global.TunSingboxDNSFileName);
await Task.CompletedTask;
});
Init();
_ = Init();
}
private async Task Init()

View File

@ -206,7 +206,7 @@ namespace ServiceLib.ViewModels
#endregion WhenAnyValue && ReactiveCommand
Init();
_ = Init();
}
private async Task Init()
@ -252,7 +252,7 @@ namespace ServiceLib.ViewModels
RefreshServers();
if (indexIdOld != _config.IndexId)
{
Reload();
_ = Reload();
}
if (_config.UiItem.EnableAutoAdjustMainLvColWidth)
{
@ -406,6 +406,7 @@ namespace ServiceLib.ViewModels
public async Task AddServerViaScanAsync()
{
_updateView?.Invoke(EViewAction.ScanScreenTask, null);
await Task.CompletedTask;
}
public async Task ScanScreenResult(byte[]? bytes)
@ -417,6 +418,7 @@ namespace ServiceLib.ViewModels
public async Task AddServerViaImageAsync()
{
_updateView?.Invoke(EViewAction.ScanImageTask, null);
await Task.CompletedTask;
}
public async Task ScanImageResult(string fileName)
@ -530,6 +532,7 @@ namespace ServiceLib.ViewModels
{
ProcUtils.ProcessStart("open", path);
}
await Task.CompletedTask;
}
#endregion Setting
@ -548,8 +551,8 @@ namespace ServiceLib.ViewModels
BlReloadEnabled = false;
await LoadCore();
Locator.Current.GetService<StatusBarViewModel>()?.TestServerAvailability();
await SysProxyHandler.UpdateSysProxy(_config, false);
Locator.Current.GetService<StatusBarViewModel>()?.TestServerAvailability();
_updateView?.Invoke(EViewAction.DispatcherReload, null);
@ -591,6 +594,7 @@ namespace ServiceLib.ViewModels
{
ShowHideWindow(false);
}
await Task.CompletedTask;
}
#endregion core job

View File

@ -105,6 +105,7 @@ namespace ServiceLib.ViewModels
{
_queueMsg.Enqueue(Environment.NewLine);
}
await Task.CompletedTask;
}
public void ClearMsg()

View File

@ -115,7 +115,7 @@ namespace ServiceLib.ViewModels
await SaveSettingAsync();
});
Init();
_ = Init();
}
private async Task Init()
@ -261,6 +261,7 @@ namespace ServiceLib.ViewModels
break;
}
});
await Task.CompletedTask;
}
private async Task SaveSettingAsync()
@ -410,6 +411,7 @@ namespace ServiceLib.ViewModels
}
item.CoreType = (ECoreType)Enum.Parse(typeof(ECoreType), type);
}
await Task.CompletedTask;
}
}
}

View File

@ -231,7 +231,7 @@ namespace ServiceLib.ViewModels
MessageBus.Current.Listen<string>(EMsgCommand.RefreshProfiles.ToString()).Subscribe(OnNext);
}
Init();
_ = Init();
}
private async Task Init()

View File

@ -257,7 +257,7 @@ namespace ServiceLib.ViewModels
return;
}
string result = Utils.LoadResource(fileName);
var result = Utils.LoadResource(fileName);
if (Utils.IsNullOrEmpty(result))
{
return;

View File

@ -67,7 +67,7 @@ namespace ServiceLib.ViewModels
await SaveRoutingAsync();
});
Init();
_ = Init();
}
private async Task Init()

View File

@ -137,6 +137,7 @@ namespace ServiceLib.ViewModels
NotifyLeftClickCmd = ReactiveCommand.CreateFromTask(async () =>
{
Locator.Current.GetService<MainWindowViewModel>()?.ShowHideWindow(null);
await Task.CompletedTask;
});
AddServerViaClipboardCmd = ReactiveCommand.CreateFromTask(async () =>
@ -180,7 +181,7 @@ namespace ServiceLib.ViewModels
{
InitUpdateView(updateView);
}
Init();
_ = Init();
}
private async Task Init()
@ -478,6 +479,7 @@ namespace ServiceLib.ViewModels
{
InboundLanDisplay = $"{ResUI.LabLAN}:{Global.None}";
}
await Task.CompletedTask;
}
public void UpdateStatistics(ServerSpeedItem update)

View File

@ -48,7 +48,7 @@ namespace ServiceLib.ViewModels
await _updateView?.Invoke(EViewAction.ShareSub, SelectedSource?.Url);
}, canEditRemove);
Init();
_ = Init();
}
private async Task Init()

View File

@ -248,7 +248,9 @@ namespace v2rayN.Views
{
Logging.SaveLog("GetFonts", ex);
}
return lstFonts.OrderBy(t => t).ToList();
var lst = lstFonts.OrderBy(t => t).ToList();
return await Task.FromResult(lst);
}
private void ClbdestOverride_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)