From aa3094f79610297930bfc5342fac6a5d1d912b9d Mon Sep 17 00:00:00 2001 From: YFdyh000 Date: Sun, 19 Apr 2020 04:11:30 +0800 Subject: [PATCH] try to speed up --- .../HttpProxyHandler/HttpProxyHandle.cs | 50 ++++++++++--------- 1 file changed, 27 insertions(+), 23 deletions(-) diff --git a/v2rayN/v2rayN/HttpProxyHandler/HttpProxyHandle.cs b/v2rayN/v2rayN/HttpProxyHandler/HttpProxyHandle.cs index 0236c5a8..142eca51 100644 --- a/v2rayN/v2rayN/HttpProxyHandler/HttpProxyHandle.cs +++ b/v2rayN/v2rayN/HttpProxyHandler/HttpProxyHandle.cs @@ -1,4 +1,5 @@ using System; +using System.Threading.Tasks; using v2rayN.Mode; namespace v2rayN.HttpProxyHandler @@ -148,33 +149,36 @@ namespace v2rayN.HttpProxyHandler /// /// /// - public static void RestartHttpAgent(Config config, bool forced) + public static Task RestartHttpAgent(Config config, bool forced) { - bool isRestart = false; - if (config.listenerType == ListenerType.noHttpProxy) - { - // 关闭http proxy时,直接返回 - return; - } - //强制重启或者socks端口变化 - if (forced) - { - isRestart = true; - } - else - { - int localPort = config.GetLocalPort(Global.InboundSocks); - if (localPort != Global.socksPort) + return Task.Run(() => + { + bool isRestart = false; + if (config.listenerType == ListenerType.noHttpProxy) + { + // 关闭http proxy时,直接返回 + return; + } + //强制重启或者socks端口变化 + if (forced) { isRestart = true; } - } - if (isRestart) - { - CloseHttpAgent(config); - StartHttpAgent(config); - } - Update(config, false); + else + { + int localPort = config.GetLocalPort(Global.InboundSocks); + if (localPort != Global.socksPort) + { + isRestart = true; + } + } + if (isRestart) + { + CloseHttpAgent(config); + StartHttpAgent(config); + } + Update(config, false); + }); } public static string GetPacUrl()