Dont crash if client is disconnected from within DiscordClient.Run

This commit is contained in:
RogueException
2015-11-11 20:25:53 -04:00
parent d39b4b0f42
commit 864fb53ab6

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>