From 9fe2541f18816acf1e5bbabec528df02f05515dd Mon Sep 17 00:00:00 2001 From: Connection Refused Date: Fri, 8 May 2020 16:41:50 +0800 Subject: [PATCH] Add wait for exit --- Netch/Controllers/DNSController.cs | 1 + Netch/Controllers/NTTController.cs | 1 + Netch/Controllers/PrivoxyController.cs | 1 + Netch/Controllers/SSController.cs | 9 +++++++-- Netch/Controllers/SSRController.cs | 1 + Netch/Controllers/VMessController.cs | 1 + 6 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Netch/Controllers/DNSController.cs b/Netch/Controllers/DNSController.cs index add9d5c2..b0564eb6 100644 --- a/Netch/Controllers/DNSController.cs +++ b/Netch/Controllers/DNSController.cs @@ -59,6 +59,7 @@ namespace Netch.Controllers if (Instance != null && !Instance.HasExited) { Instance.Kill(); + Instance.WaitForExit(); } } catch (Exception e) diff --git a/Netch/Controllers/NTTController.cs b/Netch/Controllers/NTTController.cs index 82843cab..e0003d76 100644 --- a/Netch/Controllers/NTTController.cs +++ b/Netch/Controllers/NTTController.cs @@ -73,6 +73,7 @@ namespace Netch.Controllers if (Instance != null && !Instance.HasExited) { Instance.Kill(); + Instance.WaitForExit(); } } catch (Exception e) diff --git a/Netch/Controllers/PrivoxyController.cs b/Netch/Controllers/PrivoxyController.cs index 9eedf5ac..e71ec014 100644 --- a/Netch/Controllers/PrivoxyController.cs +++ b/Netch/Controllers/PrivoxyController.cs @@ -73,6 +73,7 @@ namespace Netch.Controllers if (Instance != null && !Instance.HasExited) { Instance.Kill(); + Instance.WaitForExit(); } } catch (Exception) diff --git a/Netch/Controllers/SSController.cs b/Netch/Controllers/SSController.cs index 17a9267a..fb903f16 100644 --- a/Netch/Controllers/SSController.cs +++ b/Netch/Controllers/SSController.cs @@ -117,12 +117,17 @@ namespace Netch.Controllers { try { + if (Global.Settings.BootShadowsocksFromDLL) + { + NativeMethods.Shadowsocks.Stop(); + return; + } + if (Instance != null && !Instance.HasExited) { Instance.Kill(); + Instance.WaitForExit(); } - if (Global.Settings.BootShadowsocksFromDLL) - NativeMethods.Shadowsocks.Stop(); } catch (Exception e) { diff --git a/Netch/Controllers/SSRController.cs b/Netch/Controllers/SSRController.cs index c4daf2a1..f1b74721 100644 --- a/Netch/Controllers/SSRController.cs +++ b/Netch/Controllers/SSRController.cs @@ -106,6 +106,7 @@ namespace Netch.Controllers if (Instance != null && !Instance.HasExited) { Instance.Kill(); + Instance.WaitForExit(); } } catch (Exception e) diff --git a/Netch/Controllers/VMessController.cs b/Netch/Controllers/VMessController.cs index 2e6e4a7a..4acea7d6 100644 --- a/Netch/Controllers/VMessController.cs +++ b/Netch/Controllers/VMessController.cs @@ -216,6 +216,7 @@ namespace Netch.Controllers if (Instance != null && !Instance.HasExited) { Instance.Kill(); + Instance.WaitForExit(); } } catch (Exception e)