bool CompleteDrainLength(IAsyncResult result) { this.lengthBytes = channel.EndSocketReceiveBytes(result); if (this.lengthBytes == null) { this.buffer = new ArraySegment <byte>(); return(true); } this.dataLength = Formatting.BytesToSize(this.lengthBytes, 0); IAsyncResult readDataResult = channel.BeginSocketReceiveBytes(this.dataLength, OnReadData, this); if (!readDataResult.CompletedSynchronously) { return(false); } return(CompleteReadData(result)); }