System.Net.Http.WinHttpResponseStream.CopyToAsync C# (CSharp) Method

CopyToAsync() public method

public CopyToAsync ( Stream destination, int bufferSize, CancellationToken cancellationToken ) : Task
destination System.IO.Stream
bufferSize int
cancellationToken System.Threading.CancellationToken
return Task
        public override Task CopyToAsync(Stream destination, int bufferSize, CancellationToken cancellationToken)
        {
            // Validate arguments as would base CopyToAsync
            StreamHelpers.ValidateCopyToArgs(this, destination, bufferSize);

            // Check that there are no other pending read operations
            if (_state.AsyncReadInProgress)
            {
                throw new InvalidOperationException(SR.net_http_no_concurrent_io_allowed);
            }

            // Early check for cancellation
            if (cancellationToken.IsCancellationRequested)
            {
                return Task.FromCanceled(cancellationToken);
            }

            // Check out a buffer and start the copy
            return CopyToAsyncCore(destination, ArrayPool<byte>.Shared.Rent(bufferSize), cancellationToken);
        }