Is there a performance and/or safety issue with creating a task per iteration of a large while loop?
<p>I am querying a database and retrieving hundreds of thousands of records. I then read over the SqlReader returned and create a new task per record. The new task then does some long running operation.</p>

<p>My code looks somewhat like this:</p>

<pre><code>    void ProcessRecords(SqlDataReader reader)
    {
        if (!reader.HasRows)
        {
            return;
        }
        using (reader)
        {
            while (reader.Read())
            {
                var filePath = BuildFilePath(reader);
                var imageId = (int)reader["PhotoID"];
                Task.Run(() =&gt; { ProcessRecord(imageId, filePath); })
                    .ContinueWith((task) =&gt; { Progress.Report("Processing " + Path.GetFileName(filePath)); });
            }
        }
    }
</code></pre>

<p>I was advised by a senior developer to use a semaphore to limit the number of threads used by tasks. Is this the right way to approach this?</p>