From ccb16e40c8f111b3690f84b410b2020676b5a40d Mon Sep 17 00:00:00 2001 From: ComputerMaster1st Date: Thu, 29 Nov 2018 22:20:35 +0000 Subject: [PATCH] fix: Solves UdpClient "ObjectDisposedException" (#1202) * Solves "ObjectDisposedException" * Corrected Spelling Error * Fixed Spelling --- src/Discord.Net.WebSocket/Net/DefaultUdpSocket.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Discord.Net.WebSocket/Net/DefaultUdpSocket.cs b/src/Discord.Net.WebSocket/Net/DefaultUdpSocket.cs index 4b37de28f..82079e9bd 100644 --- a/src/Discord.Net.WebSocket/Net/DefaultUdpSocket.cs +++ b/src/Discord.Net.WebSocket/Net/DefaultUdpSocket.cs @@ -130,6 +130,14 @@ namespace Discord.Net.Udp while (!cancelToken.IsCancellationRequested) { var receiveTask = _udp.ReceiveAsync(); + + _ = receiveTask.ContinueWith((receiveResult) => + { + //observe the exception as to not receive as unhandled exception + _ = receiveResult.Exception; + + }, TaskContinuationOptions.OnlyOnFaulted); + var task = await Task.WhenAny(closeTask, receiveTask).ConfigureAwait(false); if (task == closeTask) break;