title: Is there a way to use the Task Parallel Library(TPL) with SQLDataReader?
body: <p>I like the simplicity of the Parallel.For and Parallel.ForEach extension methods in the TPL. I was wondering if there was a way to take advantage of something similar or even with the slightly more advanced Tasks.</p>
  
  <p>Below is a typical usage for the SqlDataReader, and I was wondering if it was possible and if so how to replace the while loop below with something in the TPL. Because the reader can't provide a fixed number of iterations the For extension method is not possible which leaves dealing with Tasks I would gather.  I was hoping someone may have tackled this already and worked out some do's and don''s with ADO.net.</p>
  
  <pre><code>using (SqlConnection conn = new SqlConnection("myConnString"))
  using (SqlCommand comm = new SqlCommand("myQuery", conn))
  {
      conn.Open();
  
      SqlDataReader reader = comm.ExecuteReader();
  
      if (reader.HasRows)
      {
          while (reader.Read())
          {
              // Do something with Reader
          }
      }
  }
  </code></pre>