diff options
Diffstat (limited to 'src/System.Private.CoreLib/src/System/IO/Stream.cs')
-rw-r--r-- | src/System.Private.CoreLib/src/System/IO/Stream.cs | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/System.Private.CoreLib/src/System/IO/Stream.cs b/src/System.Private.CoreLib/src/System/IO/Stream.cs index 13545cf99..42fd2cb6a 100644 --- a/src/System.Private.CoreLib/src/System/IO/Stream.cs +++ b/src/System.Private.CoreLib/src/System/IO/Stream.cs @@ -148,9 +148,10 @@ namespace System.IO Debug.Assert(destination.CanWrite); byte[] buffer = new byte[bufferSize]; - int bytesRead; - while ((bytesRead = await ReadAsync(buffer, 0, buffer.Length, cancellationToken).ConfigureAwait(false)) != 0) + while (true) { + int bytesRead = await ReadAsync(buffer, 0, buffer.Length, cancellationToken).ConfigureAwait(false); + if (bytesRead == 0) break; await destination.WriteAsync(buffer, 0, bytesRead, cancellationToken).ConfigureAwait(false); } } |