Пример #1
0
 public override async Task <TDroplet> Drip()
 {
     {
         byte[] buf = new byte[ChunkSize];
         try
         {
             if (DataAvailable(SourceStream) && await SourceStream.ReadAsync(buf, 0, ChunkSize) > 0)
             {
                 return(ReadAdapter(buf));
             }
         }
         catch { /* Fall down to InterruptFlow() */ }
     }
     await InterruptFlow(); return(default);
Пример #2
0
        public override async Task <int> ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
        {
            if (buffer is null)
            {
                throw new ArgumentNullException(nameof(buffer));
            }

            var read = await SourceStream
                       .ReadAsync(buffer, offset, count, cancellationToken)
                       .ConfigureAwait(false);

            await outStream
            .WriteAsync(buffer, offset, read, cancellationToken)
            .ConfigureAwait(false);

            return(read);
        }