From 3869148fc827e2f29159983c3c7634c6388ea2cb Mon Sep 17 00:00:00 2001 From: 2dust <31833384+2dust@users.noreply.github.com> Date: Thu, 6 Mar 2025 14:30:02 +0800 Subject: [PATCH] AI-optimized code --- v2rayN/ServiceLib/Handler/ClashApiHandler.cs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/v2rayN/ServiceLib/Handler/ClashApiHandler.cs b/v2rayN/ServiceLib/Handler/ClashApiHandler.cs index 01134e6d..d61709ed 100644 --- a/v2rayN/ServiceLib/Handler/ClashApiHandler.cs +++ b/v2rayN/ServiceLib/Handler/ClashApiHandler.cs @@ -37,7 +37,7 @@ namespace ServiceLib.Handler public void ClashProxiesDelayTest(bool blAll, List lstProxy, Action updateFunc) { - Task.Run(() => + Task.Run(async () => { if (blAll) { @@ -47,7 +47,7 @@ namespace ServiceLib.Handler { break; } - Task.Delay(5000).Wait(); + await Task.Delay(5000); } if (_proxies == null) { @@ -90,9 +90,8 @@ namespace ServiceLib.Handler updateFunc?.Invoke(it, result); })); } - Task.WaitAll(tasks.ToArray()); - - Task.Delay(1000).Wait(); + await Task.WhenAll(tasks); + await Task.Delay(1000); updateFunc?.Invoke(null, ""); }); }