How do I parallelize this pattern?
<p>I want something that does that equivalent of </p>

<pre><code>var docs = new LinkedList&lt;string&gt;();
for(int i = 0; ; ++i)
{
    string html = client.DownloadString($"http://someforum.com/page?id={i}"); 
    if(html == null)
       break;
    docs.AddLast(html);
}
</code></pre>

<p>except that would exploit the fact that  <code>client.DownloadString($"http://someforum.com/page?id={i}");</code> is a long running task that could be getting run in different threads. </p>

<p>Basically, what I'm trying to do is get the HTML from the pages</p>

<p><code>"http://someforum.com/page?id=0"</code>, <code>"http://someforum.com/page?id=1"</code>, ... </p>

<p>except that as soon as I don't get a page from <code>id=m</code> then I assume any tasks trying to get page <code>id=n</code> for some <code>n&gt;m</code> will not get a page and can be shut down.</p>