diff --git a/src/Main/Shared/SystemNetSockets/UdpSocket.cs b/src/Main/Shared/SystemNetSockets/UdpSocket.cs index 8183c6c..0cfa140 100644 --- a/src/Main/Shared/SystemNetSockets/UdpSocket.cs +++ b/src/Main/Shared/SystemNetSockets/UdpSocket.cs @@ -70,8 +70,13 @@ public System.Threading.Tasks.Task ReceiveAsync() catch (ObjectDisposedException) { if (!this.IsDisposed) throw; } //Only rethrow disposed exceptions if we're NOT disposed, because then they are unexpected. }, state); #else - _Socket.BeginReceiveFrom(state.Buffer, 0, state.Buffer.Length, System.Net.Sockets.SocketFlags.None, ref state.EndPoint, - new AsyncCallback((result) => ProcessResponse(state, () => state.Socket.EndReceiveFrom(result, ref state.EndPoint))), state); + try + { + _Socket.BeginReceiveFrom(state.Buffer, 0, state.Buffer.Length, System.Net.Sockets.SocketFlags.None, ref state.EndPoint, + new AsyncCallback((result) => ProcessResponse(state, () => state.Socket.EndReceiveFrom(result, ref state.EndPoint))), state); + } + catch (ObjectDisposedException) { if (!this.IsDisposed) throw; } //Only rethrow disposed exceptions if we're NOT disposed, because then they are unexpected. + #endif return tcs.Task;