From b1773dab9063231e39cf1cd44b1323fe2164142b Mon Sep 17 00:00:00 2001 From: YFdyh000 Date: Sat, 18 Apr 2020 11:12:09 +0800 Subject: [PATCH] bug fixes --- v2rayN/v2rayN/Base/HttpWebServerB.cs | 2 +- v2rayN/v2rayN/Forms/MainForm.Designer.cs | 1 - v2rayN/v2rayN/Forms/MainForm.cs | 26 +++++++++++++++++------- 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/v2rayN/v2rayN/Base/HttpWebServerB.cs b/v2rayN/v2rayN/Base/HttpWebServerB.cs index fcbca1dd..6434b9ea 100644 --- a/v2rayN/v2rayN/Base/HttpWebServerB.cs +++ b/v2rayN/v2rayN/Base/HttpWebServerB.cs @@ -41,7 +41,7 @@ namespace v2rayN.Base listener.Start(); Utils.SaveLog("WebserverB running..."); - while (true) + while (true && listener != null) { if (!listener.Pending()) { diff --git a/v2rayN/v2rayN/Forms/MainForm.Designer.cs b/v2rayN/v2rayN/Forms/MainForm.Designer.cs index f4b06e04..9b2db76a 100644 --- a/v2rayN/v2rayN/Forms/MainForm.Designer.cs +++ b/v2rayN/v2rayN/Forms/MainForm.Designer.cs @@ -163,7 +163,6 @@ this.lvServers.HideSelection = false; this.lvServers.Items.AddRange(new System.Windows.Forms.ListViewItem[] { ((System.Windows.Forms.ListViewItem)(resources.GetObject("lvServers.Items")))}); - this.lvServers.MultiSelect = false; this.lvServers.Name = "lvServers"; this.lvServers.UseCompatibleStateImageBehavior = false; this.lvServers.View = System.Windows.Forms.View.Details; diff --git a/v2rayN/v2rayN/Forms/MainForm.cs b/v2rayN/v2rayN/Forms/MainForm.cs index 1c40611a..59cb17a2 100644 --- a/v2rayN/v2rayN/Forms/MainForm.cs +++ b/v2rayN/v2rayN/Forms/MainForm.cs @@ -445,12 +445,19 @@ namespace v2rayN.Forms /// private void Closes() { - //ConfigHandler.SaveConfig(ref config, false); // ChangePACButtonStatus does it. - Task.Run(() => ChangePACButtonStatus(ListenerType.noHttpProxy)); - Task.Run(() => v2rayHandler.V2rayStop()); - Task.Run(() => PACServerHandle.Stop()); - statistics?.SaveToFile(); - statistics?.Close(); + List tasks = new List + { + Task.Run(() => ConfigHandler.SaveConfig(ref config)), + Task.Run(() => HttpProxyHandle.CloseHttpAgent(config)), + Task.Run(() => v2rayHandler.V2rayStop()), + Task.Run(() => PACServerHandle.Stop()), + Task.Run(() => + { + statistics?.SaveToFile(); + statistics?.Close(); + }) + }; + Task.WaitAll(tasks.ToArray()); } #endregion @@ -1130,6 +1137,7 @@ namespace v2rayN.Forms int index = statistics.FindIndex(item_ => item_.itemId == config.vmess[i].getItemId()); if (index != -1) { + if (lvServers == null) return; // The app is exiting. lvServers.Invoke((MethodInvoker)delegate { lvServers.BeginUpdate(); @@ -1259,7 +1267,11 @@ namespace v2rayN.Forms Global.reloadV2ray = false; ConfigHandler.SaveConfig(ref config); - DisplayToolStatus(); + + this.Invoke((MethodInvoker)(delegate + { + DisplayToolStatus(); + })); } #endregion