private Flush ( byte outputBuffer, int &bytesRead ) : bool | ||
outputBuffer | byte | |
bytesRead | int | |
return | bool |
private async Task FlushAsyncCore(CancellationToken cancellationToken) { AsyncOperationStarting(); try { // Compress any bytes left: await WriteDeflaterOutputAsync(cancellationToken).ConfigureAwait(false); // Pull out any bytes left inside deflater: bool flushSuccessful; do { int compressedBytes; flushSuccessful = _deflater.Flush(_buffer, out compressedBytes); if (flushSuccessful) { await _stream.WriteAsync(_buffer, 0, compressedBytes, cancellationToken).ConfigureAwait(false); } Debug.Assert(flushSuccessful == (compressedBytes > 0)); } while (flushSuccessful); } finally { AsyncOperationCompleting(); } }
// This is called by Flush: private void FlushBuffers() { // Make sure to only "flush" when we actually had some input: if (_wroteBytes) { // Compress any bytes left: WriteDeflaterOutput(); // Pull out any bytes left inside deflater: bool flushSuccessful; do { int compressedBytes; flushSuccessful = _deflater.Flush(_buffer, out compressedBytes); if (flushSuccessful) { _stream.Write(_buffer, 0, compressedBytes); } Debug.Assert(flushSuccessful == (compressedBytes > 0)); } while (flushSuccessful); } }