From 6c5a34eaa60091ea61f69456b8d8d4df0825a738 Mon Sep 17 00:00:00 2001 From: Nabile Rahmani Date: Mon, 10 Dec 2018 19:46:30 +0100 Subject: [PATCH] Updater: Delay executable file replace on Windows using the ProcessExit event. This should match the Linux behaviour where the process can keep running after updating. --- DotN64.Desktop/Updater.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/DotN64.Desktop/Updater.cs b/DotN64.Desktop/Updater.cs index 158268d..2da7838 100644 --- a/DotN64.Desktop/Updater.cs +++ b/DotN64.Desktop/Updater.cs @@ -145,19 +145,17 @@ namespace DotN64.Desktop writer.WriteLine(":UPDATE"); writer.WriteLine($"move /Y \"{newExecutableName}\" \"{executableName}\""); - //writer.WriteLine($"start \"\" \"{executableName}\""); // It's pointless to automatically restart the program as it'll crash with no arguments in its current state. writer.WriteLine($"del /A:H %0"); } scriptFile.Attributes |= FileAttributes.Hidden; - Process.Start(new ProcessStartInfo(scriptFile.FullName) + AppDomain.CurrentDomain.ProcessExit += (s, e) => Process.Start(new ProcessStartInfo(scriptFile.FullName) { UseShellExecute = false, CreateNoWindow = true, WorkingDirectory = InstallDirectory }); - Environment.Exit(0); } #endregion }