From 323699d1030fa0bd47e664d551bd4980d06674dc Mon Sep 17 00:00:00 2001 From: Kwoth Date: Thu, 3 Mar 2022 01:13:49 +0100 Subject: [PATCH] Small change to Bot.cs to pinpoint the logging in hang issue --- src/NadekoBot/Bot.cs | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/src/NadekoBot/Bot.cs b/src/NadekoBot/Bot.cs index de70503a1..ce0ee074e 100644 --- a/src/NadekoBot/Bot.cs +++ b/src/NadekoBot/Bot.cs @@ -216,24 +216,20 @@ public sealed class Bot private async Task LoginAsync(string token) { - var clientReady = new TaskCompletionSource(); + var clientReady = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); - Task SetClientReady() + async Task SetClientReady() { - _ = Task.Run(async () => + clientReady.TrySetResult(true); + try { - clientReady.TrySetResult(true); - try - { - foreach (var chan in await Client.GetDMChannelsAsync()) - await chan.CloseAsync(); - } - catch - { - // ignored - } - }); - return Task.CompletedTask; + foreach (var chan in await Client.GetDMChannelsAsync()) + await chan.CloseAsync(); + } + catch + { + // ignored + } } //connect @@ -241,6 +237,7 @@ public sealed class Bot try { await Client.LoginAsync(TokenType.Bot, token); + Log.Information("Starting..."); await Client.StartAsync(); } catch (HttpException ex)