Don't bother with nice shutdown, closes #94

We really don't need any of that when we're exiting process anyway, framework does that better
This commit is contained in:
JustArchi
2016-02-03 05:57:58 +01:00
parent c5ac0196de
commit e4189b2bc4
2 changed files with 6 additions and 16 deletions

View File

@@ -114,14 +114,6 @@ namespace ArchiSteamFarm {
return Bots.Count;
}
internal static async Task ShutdownAllBots() {
List<Task> tasks = new List<Task>();
foreach (Bot bot in Bots.Values) {
tasks.Add(Task.Run(async () => await bot.Shutdown().ConfigureAwait(false)));
}
await Task.WhenAll(tasks).ConfigureAwait(false);
}
internal static void RefreshCMs() {
bool initialized = false;
while (!initialized) {
@@ -832,10 +824,10 @@ namespace ArchiSteamFarm {
case "!2faoff":
return Response2FAOff(BotName);
case "!exit":
await ShutdownAllBots().ConfigureAwait(false);
Program.Exit();
return "Done";
case "!restart":
await Program.Restart().ConfigureAwait(false);
Program.Restart();
return "Done";
case "!status":
return ResponseStatus();

View File

@@ -93,15 +93,13 @@ namespace ArchiSteamFarm {
}
}
internal static async Task Exit(int exitCode = 0) {
await Bot.ShutdownAllBots().ConfigureAwait(false);
internal static void Exit(int exitCode = 0) {
Environment.Exit(exitCode);
}
internal static async Task Restart() {
await Bot.ShutdownAllBots().ConfigureAwait(false);
internal static void Restart() {
System.Diagnostics.Process.Start(ExecutableFile, string.Join(" ", Environment.GetCommandLineArgs()));
Environment.Exit(0);
Exit();
}
internal static async Task LimitSteamRequestsAsync() {
@@ -259,7 +257,7 @@ namespace ArchiSteamFarm {
if (!Directory.Exists(ConfigDirectory)) {
Logging.LogGenericError("Config directory doesn't exist!");
Thread.Sleep(5000);
Task.Run(async () => await Exit(1).ConfigureAwait(false)).Wait();
Exit(1);
}
// Before attempting to connect, initialize our list of CMs