Browse Source

Dont crash if client is disconnected from within DiscordClient.Run

tags/docs-0.9
RogueException 9 years ago
parent
commit
864fb53ab6
1 changed files with 5 additions and 1 deletions
  1. +5
    -1
      src/Discord.Net/DiscordWSClient.cs

+ 5
- 1
src/Discord.Net/DiscordWSClient.cs View File

@@ -257,7 +257,11 @@ namespace Discord
/// <summary> Blocking call that will not return until client has been stopped. This is mainly intended for use in console applications. </summary>
public void Run(Func<Task> asyncAction)
{
asyncAction().Wait();
try
{
asyncAction().Wait();
}
catch (AggregateException ex) when (ex.InnerException is TaskCanceledException) { }
_disconnectedEvent.WaitOne();
}
/// <summary> Blocking call that will not return until client has been stopped. This is mainly intended for use in console applications. </summary>


Loading…
Cancel
Save