Wait for ctrl-c before exiting
This commit is contained in:
parent
faa36441aa
commit
627eaac647
|
@ -33,7 +33,13 @@ var iBotCommands = new List<string> {
|
|||
|
||||
bot.StartReceiving(HandleUpdateAsync, PollingErrorHandler, null, cts.Token);
|
||||
Console.WriteLine($"Start listening for @{me.Username}");
|
||||
do { } while (Console.ReadLine() != "exit");
|
||||
|
||||
var exitEvent = new ManualResetEvent(false);
|
||||
Console.CancelKeyPress += (sender, eventArgs) => {
|
||||
eventArgs.Cancel = true;
|
||||
exitEvent.Set();
|
||||
};
|
||||
exitEvent.WaitOne();
|
||||
|
||||
cts.Cancel();
|
||||
|
||||
|
|
Loading…
Reference in a new issue