Ignore errors during AudioClient cleanup

This commit is contained in:
RogueException
2016-01-30 12:23:47 -04:00
parent 780da1ce1e
commit 30196bd43f
2 changed files with 15 additions and 5 deletions

View File

@@ -129,11 +129,19 @@ namespace Discord.Net.WebSockets
protected override async Task Cleanup() protected override async Task Cleanup()
{ {
var sendThread = _sendTask; var sendThread = _sendTask;
if (sendThread != null) await sendThread.ConfigureAwait(false); if (sendThread != null)
{
try { await sendThread.ConfigureAwait(false); }
catch (Exception) { } //Ignore any errors during cleanup
}
_sendTask = null; _sendTask = null;
var receiveThread = _receiveTask; var receiveThread = _receiveTask;
if (receiveThread != null) await receiveThread.ConfigureAwait(false); if (receiveThread != null)
{
try { await receiveThread.ConfigureAwait(false); }
catch (Exception) { } //Ignore any errors during cleanup
}
_receiveTask = null; _receiveTask = null;
OpusDecoder decoder; OpusDecoder decoder;
@@ -384,8 +392,11 @@ namespace Discord.Net.WebSockets
} }
#if !DOTNET5_4 #if !DOTNET5_4
//Closes the UDP socket when _disconnectToken is triggered, since UDPClient doesn't allow passing a canceltoken //Closes the UDP socket when _disconnectToken is triggered, since UDPClient doesn't allow passing a canceltoken
private Task WatcherAsync() private async Task WatcherAsync()
=> CancelToken.Wait().ContinueWith(_ => _udp.Close()); {
await CancelToken.Wait();
_udp.Close();
}
#endif #endif
protected override async Task ProcessMessage(string json) protected override async Task ProcessMessage(string json)

View File

@@ -278,7 +278,6 @@ namespace Discord
if (Config.UseMessageQueue) if (Config.UseMessageQueue)
MessageQueue.Clear(); MessageQueue.Clear();
await GatewaySocket.Disconnect().ConfigureAwait(false); await GatewaySocket.Disconnect().ConfigureAwait(false);
ClientAPI.Token = null; ClientAPI.Token = null;