Dont crash if the websocket's cancelTokenSource.Cancel throws an exception
This commit is contained in:
@@ -72,17 +72,13 @@ namespace Discord.Net.WebSockets
|
|||||||
public async Task DisconnectAsync()
|
public async Task DisconnectAsync()
|
||||||
{
|
{
|
||||||
//Assume locked
|
//Assume locked
|
||||||
_cancelTokenSource.Cancel();
|
try { _cancelTokenSource.Cancel(false); } catch { }
|
||||||
|
|
||||||
if (_client != null && _client.State == WebSocketState.Open)
|
if (_client != null && _client.State == WebSocketState.Open)
|
||||||
{
|
{
|
||||||
try
|
var task = _client?.CloseOutputAsync(WebSocketCloseStatus.NormalClosure, "", CancellationToken.None);
|
||||||
{
|
if (task != null)
|
||||||
var task = _client?.CloseOutputAsync(WebSocketCloseStatus.NormalClosure, "", CancellationToken.None);
|
await task.ConfigureAwait(false);
|
||||||
if (task != null)
|
|
||||||
await task.ConfigureAwait(false);
|
|
||||||
}
|
|
||||||
catch { }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
await (_task ?? Task.CompletedTask).ConfigureAwait(false);
|
await (_task ?? Task.CompletedTask).ConfigureAwait(false);
|
||||||
|
|||||||
Reference in New Issue
Block a user