Ejemplo n.º 1
0
        public static ValueTask CopyToAsync(this IBufferReader <byte> source, Stream target, CancellationToken token) => source.CopyToAsync(target, 81920, token);        // Same buffer size as Stream.CopyTo

        /// <summary>
        /// Asynchronously reads the bytes from the current <see cref="IBufferReader{Byte}"/> and writes them to a Stream
        /// </summary>
        /// <param name="source">The current buffer reader to read from</param>
        /// <param name="target">The stream to write to</param>
        /// <param name="blockSize">The size of the blocks to read and write</param>
        /// <returns>A Task that completes when the stream has been read to completion</returns>
        public static ValueTask CopyToAsync(this IBufferReader <byte> source, Stream target, int blockSize) => source.CopyToAsync(target, blockSize, CancellationToken.None);
Ejemplo n.º 2
0
        public static ValueTask CopyToAsync(this IBufferReader <byte> source, Stream target) => source.CopyToAsync(target, 81920, CancellationToken.None);        // Same buffer size as Stream.CopyTo

        /// <summary>
        /// Asynchronously reads the bytes from the current <see cref="IBufferReader{Byte}"/> and writes them to a Stream
        /// </summary>
        /// <param name="source">The current buffer reader to read from</param>
        /// <param name="target">The stream to write to</param>
        /// <param name="token">A cancellation token to abort the operation</param>
        /// <returns>A Task that completes when the stream has been read to completion</returns>
        public static ValueTask CopyToAsync(this IBufferReader <byte> source, Stream target, CancellationToken token) => source.CopyToAsync(target, 81920, token);        // Same buffer size as Stream.CopyTo