title: Using cancellation token properly in c#
body: <p>I was recently exposed to C# language and was working on getting data out of cassandra so I was working with below code which gets data from Cassandra and it works fine.</p>
  
  <p>Only problem I have is in my <code>ProcessCassQuery</code> method - I am passing <code>CancellationToken.None</code> to my <code>requestExecuter</code> Function which might not be the right thing to do. What should be the right way to handle that case and what should I do to handle it correctly?</p>
  
  <pre><code>/**
   *
   * Below method does multiple async calls on each table for their corresponding id's by limiting it down using Semaphore.
   *
   */
  private async Task&lt;List&lt;T&gt;&gt; ProcessCassQueries&lt;T&gt;(IList&lt;int&gt; ids, Func&lt;CancellationToken, int, Task&lt;T&gt;&gt; mapperFunc, string msg) where T : class
  {
      var tasks = ids.Select(async id =&gt; 
      {
          await semaphore.WaitAsync();
          try
          {
              ProcessCassQuery(ct =&gt; mapperFunc(ct, id), msg);
          }
          finally
          {
              semaphore.Release();
          }
      });
  
    return (await Task.WhenAll(tasks)).Where(e =&gt; e != null).ToList();
  }
  
  // this might not be good idea to do it. how can I improve below method?
  private Task&lt;T&gt; ProcessCassQuery&lt;T&gt;(Func&lt;CancellationToken, Task&lt;T&gt;&gt; requestExecuter, string msg) where T : class
  {
      return requestExecuter(CancellationToken.None);
  }
  </code></pre>