private void ReceiveAsyncCompleted(object sender, SocketAsyncEventArgs recvArgs) { var received = recvArgs.BytesTransferred; if (trace.IsEnabled()) { trace.ReceiveChunk(name, IsAlive, received, recvArgs.SocketError); } var success = recvArgs.SocketError == SocketError.Success && received > 0; recvBuffer.SetAvailableLength(success ? received : 0); FinishReceiving(success); }
private void ReceiveAsyncCompleted(object sender, SocketAsyncEventArgs recvArgs) { var received = recvArgs.BytesTransferred; CoreEventSource.ReceiveChunk(name, IsAlive, received, recvArgs.SocketError); var success = recvArgs.SocketError == SocketError.Success && received > 0; recvBuffer.SetDataLength(success ? received : 0); CoreEventSource.ReceiveStop(name, IsAlive, success); Volatile.Write(ref isReceiving, 0); ((Action <bool>)recvArgs.UserToken).Invoke(success); }