Browse Source

fix: Solves UdpClient "ObjectDisposedException" (#1202)

* Solves "ObjectDisposedException"

* Corrected Spelling Error

* Fixed Spelling
tags/2.0
ComputerMaster1st Christopher F 6 years ago
parent
commit
ccb16e40c8
1 changed files with 8 additions and 0 deletions
  1. +8
    -0
      src/Discord.Net.WebSocket/Net/DefaultUdpSocket.cs

+ 8
- 0
src/Discord.Net.WebSocket/Net/DefaultUdpSocket.cs View File

@@ -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;


Loading…
Cancel
Save