Optimizing Task Code

This commit is contained in:
2dust
2025-03-03 16:57:55 +08:00
parent 837cfbd03b
commit 7fbb0013b0
4 changed files with 34 additions and 33 deletions
+2 -2
View File
@@ -7,9 +7,9 @@ namespace ServiceLib.Handler
private static readonly Lazy<ClashApiHandler> instance = new(() => new());
public static ClashApiHandler Instance => instance.Value;
private static readonly string _tag = "ClashApiHandler";
private Dictionary<string, ProxiesItem>? _proxies;
public Dictionary<string, object> ProfileContent { get; set; }
private static readonly string _tag = "ClashApiHandler";
public async Task<Tuple<ClashProxies, ClashProviders>?> GetClashProxiesAsync(Config config)
{
@@ -54,7 +54,7 @@ namespace ServiceLib.Handler
return;
}
lstProxy = new List<ClashProxyModel>();
foreach (KeyValuePair<string, ProxiesItem> kv in _proxies)
foreach (var kv in _proxies)
{
if (Global.notAllowTestType.Contains(kv.Value.type.ToLower()))
{
+3 -3
View File
@@ -26,7 +26,7 @@ namespace ServiceLib.Handler
//Execute once 20 minute
if (numOfExecuted % 20 == 0)
{
Logging.SaveLog("Execute save config");
//Logging.SaveLog("Execute save config");
await ConfigHandler.SaveConfig(config);
await ProfileExHandler.Instance.SaveTo();
@@ -35,7 +35,7 @@ namespace ServiceLib.Handler
//Execute once 1 hour
if (numOfExecuted % 60 == 0)
{
Logging.SaveLog("Execute delete expired files");
//Logging.SaveLog("Execute delete expired files");
FileManager.DeleteExpiredFiles(Utils.GetBinConfigPath(), DateTime.Now.AddHours(-1));
FileManager.DeleteExpiredFiles(Utils.GetLogPath(), DateTime.Now.AddMonths(-1));
@@ -72,7 +72,7 @@ namespace ServiceLib.Handler
updateFunc?.Invoke(success, msg);
if (success)
{
Logging.SaveLog("Update subscription end" + msg);
Logging.SaveLog($"Update subscription end. {msg}");
}
});
item.UpdateTime = updateTime;