Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,10 @@ public override Task CopyToAsync(Stream destination, int bufferSize, Cancellatio
if (_completedSegments == null)
{
// There is only one segment so write without awaiting.
return destination.WriteAsync(_currentSegment, 0, _position);
return destination.WriteAsync(_currentSegment, 0, _position, cancellationToken);
}

return CopyToSlowAsync(destination);
return CopyToSlowAsync(destination, cancellationToken);
}

private void EnsureCapacity(int sizeHint)
Expand Down Expand Up @@ -184,7 +184,7 @@ private void AddSegment(int sizeHint = 0)
_position = 0;
}

private async Task CopyToSlowAsync(Stream destination)
private async Task CopyToSlowAsync(Stream destination, CancellationToken cancellationToken)
{
if (_completedSegments != null)
{
Expand All @@ -193,11 +193,11 @@ private async Task CopyToSlowAsync(Stream destination)
for (var i = 0; i < count; i++)
{
var segment = _completedSegments[i];
await destination.WriteAsync(segment.Buffer, 0, segment.Length);
await destination.WriteAsync(segment.Buffer, 0, segment.Length, cancellationToken);
}
}

await destination.WriteAsync(_currentSegment, 0, _position);
await destination.WriteAsync(_currentSegment, 0, _position, cancellationToken);
}

public byte[] ToArray()
Expand Down