Improve exit/restart

This commit is contained in:
JustArchi
2016-04-02 13:08:43 +02:00
parent 71215d695e
commit 72fa98cb89
2 changed files with 14 additions and 9 deletions

View File

@@ -682,8 +682,8 @@ namespace ArchiSteamFarm {
return null;
}
Environment.Exit(0);
return null;
Program.Exit(0);
return "Done!";
}
private string ResponseFarm(ulong steamID) {
@@ -900,7 +900,7 @@ namespace ArchiSteamFarm {
}
Program.Restart();
return null;
return "Done!";
}
private async Task<string> ResponseAddLicense(ulong steamID, HashSet<uint> gameIDs) {

View File

@@ -247,10 +247,15 @@ namespace ArchiSteamFarm {
Restart();
}
internal static void Exit(int exitCode = 0) {
WCF.StopServer();
Environment.Exit(exitCode);
}
internal static void Restart() {
try {
Process.Start(ExecutableFile, string.Join(" ", Environment.GetCommandLineArgs().Skip(1)));
Environment.Exit(0);
Exit();
} catch (Exception e) {
Logging.LogGenericException(e);
}
@@ -337,14 +342,14 @@ namespace ArchiSteamFarm {
if (GlobalConfig == null) {
Logging.LogGenericError("Global config could not be loaded, please make sure that ASF.json exists and is valid!");
Thread.Sleep(5000);
Environment.Exit(1);
Exit(1);
}
GlobalDatabase = GlobalDatabase.Load();
if (GlobalDatabase == null) {
Logging.LogGenericError("Global database could not be loaded!");
Thread.Sleep(5000);
Environment.Exit(1);
Exit(1);
}
ArchiWebHandler.Init();
@@ -445,7 +450,7 @@ namespace ArchiSteamFarm {
// If we ran ASF as a client, we're done by now
if (Mode == EMode.Client) {
Environment.Exit(0);
Exit();
}
// From now on it's server mode
@@ -454,7 +459,7 @@ namespace ArchiSteamFarm {
if (!Directory.Exists(ConfigDirectory)) {
Logging.LogGenericError("Config directory doesn't exist!");
Thread.Sleep(5000);
Environment.Exit(1);
Exit(1);
}
CheckForUpdate().Wait();
@@ -494,7 +499,7 @@ namespace ArchiSteamFarm {
ShutdownResetEvent.WaitOne();
// We got a signal to shutdown
Environment.Exit(0);
Exit();
}
}
}