1
0
mirror of https://github.com/chylex/.NET-Community-Toolkit.git synced 2025-02-23 13:46:00 +01:00

Implement MemorySource<TSource>.CopyToAsync via WriteAsync

This commit is contained in:
Oron Feinerman 2022-05-24 12:50:26 +03:00
parent b66f7c5134
commit 64587e248e

View File

@ -119,9 +119,13 @@ public sealed override Task CopyToAsync(Stream destination, int bufferSize, Canc
try
{
CopyTo(destination, bufferSize);
MemoryStream.ValidateDisposed(this.disposed);
return Task.CompletedTask;
Memory<byte> source = this.source.Memory.Slice(this.position);
this.position += source.Length;
return destination.WriteAsync(source, cancellationToken).AsTask();
}
catch (OperationCanceledException e)
{