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:
parent
b66f7c5134
commit
64587e248e
@ -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)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user