From 3544f521f9a3cc235f38018ff898a9130b14bd20 Mon Sep 17 00:00:00 2001 From: Basique Evangelist Date: Sat, 16 May 2020 23:46:59 +0300 Subject: [PATCH] Try to only stop the bot once This was causing errors on CTRL+C. --- JetKarmaBot/JetKarmaBot.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/JetKarmaBot/JetKarmaBot.cs b/JetKarmaBot/JetKarmaBot.cs index 9e6e8c2..374afaf 100644 --- a/JetKarmaBot/JetKarmaBot.cs +++ b/JetKarmaBot/JetKarmaBot.cs @@ -27,6 +27,7 @@ namespace JetKarmaBot RequestChain Chain; Task timeoutWaitTask; CancellationTokenSource timeoutWaitTaskToken; + private bool stopped = false; public async Task Init() { @@ -52,6 +53,7 @@ namespace JetKarmaBot public async Task Stop() { + if (stopped) return; Client.StopReceiving(); timeoutWaitTaskToken.Cancel(); try @@ -61,6 +63,7 @@ namespace JetKarmaBot catch (OperationCanceledException) { } await Timeout.Save(); Dispose(); + stopped = true; } #region service