Try to only stop the bot once

This was causing errors on CTRL+C.
This commit is contained in:
Basique Evangelist 2020-05-16 23:46:59 +03:00
parent 09c07e6296
commit 3544f521f9
Signed by untrusted user: BasiqueEvangelist
GPG Key ID: B370219149301706

View File

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