fix: Solves UdpClient "ObjectDisposedException" (#1202)

* Solves "ObjectDisposedException"

* Corrected Spelling Error

* Fixed Spelling
This commit is contained in:
ComputerMaster1st
2018-11-29 22:20:35 +00:00
committed by Christopher F
parent 2c93363653
commit ccb16e40c8

View File

@@ -130,6 +130,14 @@ namespace Discord.Net.Udp
while (!cancelToken.IsCancellationRequested) while (!cancelToken.IsCancellationRequested)
{ {
var receiveTask = _udp.ReceiveAsync(); 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); var task = await Task.WhenAny(closeTask, receiveTask).ConfigureAwait(false);
if (task == closeTask) if (task == closeTask)
break; break;