Skip to content

Commit

Permalink
Merge branch 'Fix/UwpDisposeExceptions'
Browse files Browse the repository at this point in the history
  • Loading branch information
Troy Willmot committed May 16, 2017
2 parents 9277a9c + d43aa06 commit fbcca3e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/Main/Rssdp.Shared/AssemblyInfoCommon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
[assembly: AssemblyCopyright("Released under the MIT license; http://choosealicense.com/licenses/mit/; https://github.com/Yortw/RSSDP")]
[assembly: AssemblyTrademark("")]

[assembly: AssemblyVersion("3.5.0.0")]
[assembly: AssemblyFileVersion("3.5.0.0")]
[assembly: AssemblyVersion("3.5.2.0")]
[assembly: AssemblyFileVersion("3.5.2.0")]
14 changes: 10 additions & 4 deletions src/Main/Shared/SystemNetSockets/UdpSocket.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,18 @@ public System.Threading.Tasks.Task<ReceivedUdpData> ReceiveAsync()
_Socket.ReceiveFromAsync(new System.ArraySegment<Byte>(state.Buffer), System.Net.Sockets.SocketFlags.None, state.EndPoint)
.ContinueWith((task, asyncState) =>
{
if (task.Status != TaskStatus.Faulted)
if (this.IsDisposed) return;

try
{
var receiveState = asyncState as AsyncReceiveState;
receiveState.EndPoint = task.Result.RemoteEndPoint;
ProcessResponse(receiveState, () => task.Result.ReceivedBytes);
if (task.Status != TaskStatus.Faulted)
{
var receiveState = asyncState as AsyncReceiveState;
receiveState.EndPoint = task.Result.RemoteEndPoint;
ProcessResponse(receiveState, () => task.Result.ReceivedBytes);
}
}
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,
Expand Down

0 comments on commit fbcca3e

Please sign in to comment.