Updates: Avoid Application.Exit usage, attempt to kill existing processes before upgrade

This commit is contained in:
Sour 2019-10-14 15:05:36 -04:00
parent e01bedee18
commit 2a7bf4df42
4 changed files with 14 additions and 3 deletions

View file

@ -148,7 +148,7 @@ namespace Mesen.GUI.Forms
private void lblCancel_Click(object sender, EventArgs e) private void lblCancel_Click(object sender, EventArgs e)
{ {
Application.Exit(); Close();
} }
private void radStoragePortable_CheckedChanged(object sender, EventArgs e) private void radStoragePortable_CheckedChanged(object sender, EventArgs e)

View file

@ -120,7 +120,7 @@ namespace Mesen.GUI.Forms
this.BeginInvoke((MethodInvoker)(() => { this.BeginInvoke((MethodInvoker)(() => {
using(frmUpdatePrompt frmUpdate = new frmUpdatePrompt(currentVersion, latestVersion, changeLog, fileHash, donateText)) { using(frmUpdatePrompt frmUpdate = new frmUpdatePrompt(currentVersion, latestVersion, changeLog, fileHash, donateText)) {
if(frmUpdate.ShowDialog(null, this) == DialogResult.OK) { if(frmUpdate.ShowDialog(null, this) == DialogResult.OK) {
Application.Exit(); Close();
} }
} }
})); }));

View file

@ -95,7 +95,6 @@ namespace Mesen.GUI
Application.Run(new frmConfigWizard()); Application.Run(new frmConfigWizard());
if(ConfigManager.GetConfigFile() == null) { if(ConfigManager.GetConfigFile() == null) {
Application.Exit();
return; return;
} }
} }

View file

@ -19,6 +19,18 @@ namespace MesenUpdater
string backupDestFile = args[2]; string backupDestFile = args[2];
bool isAdmin = args.Length > 3 && args[3] == "admin"; bool isAdmin = args.Length > 3 && args[3] == "admin";
//Wait a bit for the application to shut down before trying to kill it
System.Threading.Thread.Sleep(1000);
try {
foreach(Process process in Process.GetProcessesByName("Mesen-S")) {
try {
if(process.MainModule.FileName == destFile) {
process.Kill();
}
} catch { }
}
} catch { }
int retryCount = 0; int retryCount = 0;
while(retryCount < 10) { while(retryCount < 10) {
try { try {