From 6788c0ea914edefecebccad1b8a6fb695c03b843 Mon Sep 17 00:00:00 2001 From: Ravi Patel Date: Sat, 1 Jun 2024 22:10:13 +0530 Subject: [PATCH] Now killing the other app process only if it didn't exited after call to CloseMainWindow. --- AutoUpdater.NET/AutoUpdater.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/AutoUpdater.NET/AutoUpdater.cs b/AutoUpdater.NET/AutoUpdater.cs index 685df31..32e9baa 100644 --- a/AutoUpdater.NET/AutoUpdater.cs +++ b/AutoUpdater.NET/AutoUpdater.cs @@ -583,11 +583,6 @@ internal static void Exit() var currentProcess = Process.GetCurrentProcess(); foreach (Process process in Process.GetProcessesByName(currentProcess.ProcessName)) { - if (process.HasExited) - { - continue; - } - try { string processPath = process.MainModule?.FileName; @@ -604,6 +599,11 @@ internal static void Exit() .TotalMilliseconds); // Give some time to process message } + if (process.HasExited) + { + continue; + } + process.Kill(); //TODO: Show UI message asking user to close program himself instead of silently killing it } catch (Exception)