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

@@ -256,8 +256,12 @@ namespace Discord
//Helpers
/// <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)
{
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>