title: how to read remaining items in `Channel` less than batch size if there is no new items coming to `Channel` within X minutes
body: <p>I am using <code>Channel</code> from <code>System.Threading.Channels</code> and wants to read items in batch (5 items) and I have a method like below,</p>
  <pre><code>public class Batcher
  {
      private readonly Channel&lt;MeasurementViewModel&gt; _channel;
      public Batcher()
      {
          _channel = Channel.CreateUnbounded&lt;MeasurementViewModel&gt;();
      }
      public async Task&lt;MeasurementViewModel[]&gt; ReadBatchAsync(int batchSize, CancellationToken stoppingToken)
      {
          var result = new MeasurementViewModel[batchSize];
  
          for (var i = 0; i &lt; batchSize; i++)
          {
              result[i] = await _channel.Reader.ReadAsync(stoppingToken);
          }
  
          return result;
      }
  }
  </code></pre>
  <p>and in asp.net core background service I am using it like below,</p>
  <pre><code>public class WriterService : BackgroundService
  {
      private readonly Batcher _batcher;
      public WriterService(Batcher batcher)
      {
          _batcher = batcher;
      }
  
      protected override async Task ExecuteAsync(CancellationToken stoppingToken)
      {
          while (!stoppingToken.IsCancellationRequested)
          {
              var batchOfItems = await _batcher.ReadBatchAsync(5, stoppingToken);
  
              var range = string.Join(',', batchOfItems.Select(item =&gt; item.Value));
  
              var x = range;
          }
      }
  }
  </code></pre>
  <p>and this is working and whenever there is 5 items in <code>Channel</code>, I am getting <code>range</code>.</p>
  <p>Question is, when there are only 2 items left in <code>Channel</code> and since last 10 minutes NO items coming to <code>Channel</code>, then how to read the remaining 2 items in <code>Channel</code>?</p>