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.
master
Nabile Rahmani 2018-12-10 19:46:30 +01:00
parent ed96d4af96
commit 6c5a34eaa6
1 changed files with 1 additions and 3 deletions

View File

@ -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
}