public async Task <int> ReadNextMessagesAsync(Stream outputMessageStream) { MessageCount = 0; RemainingMessageDataSize = 0; var previousStreamPosition = outputMessageStream.Position; outputMessageStream.Position = outputMessageStream.Length; try { while (true) { await DataStreamBuffer.ReadFromAsync(InputStream).ConfigureAwait(false); //Populate the buffer if (!ProcessStream(outputMessageStream)) { break; } } CheckEndOfStreamValidity(); } finally { outputMessageStream.Position = previousStreamPosition; DataStreamBuffer.Reset(); } return(MessageCount); }
public int ReadNextMessages(Stream outputMessageStream) { MessageCount = 0; RemainingMessageDataSize = 0; var previousStreamPosition = outputMessageStream.Position; outputMessageStream.Position = outputMessageStream.Length; try { while (true) { DataStreamBuffer.ReadFrom(InputStream); //Populate the buffer if (!ProcessStream(outputMessageStream)) { break; } } CheckEndOfStreamValidity(); } finally { outputMessageStream.Position = previousStreamPosition; DataStreamBuffer.Reset(); } return(MessageCount); }