title: Httpclient tpl parallel multiple request fastest way
body: <p>I want to download webPages content of url list (10 000 urls). </p>
  
  <ol>
  <li>Is httpCLient the fastest and cleanest way (instead httpwebrequest, or webclient)?</li>
  <li>If I want to be fast, Is TPL the best way ?</li>
  </ol>
  
  <p>I'm looking for something like, but really fast and clean (10 000 request) ?</p>
  
  <pre><code>public List&lt;string&gt; GetContentListOfUrlList(List&lt;Uri&gt; uriList, int maxSimultaneousRequest)
      {
          //requesting url by the fastest way
  
      }
  </code></pre>
  
  <p>I hope is better like this ;)</p>
  
  <p>EDIT 2 :
  According to noseratio <a href="https://stackoverflow.com/questions/22492383/throttling-asynchronous-tasks/22493662#22493662">other post</a>
  <strong>Is the best solution ?</strong></p>
  
  <pre><code>public async Task&lt;List&lt;string&gt;&gt; DownloadAsync(List&lt;Uri&gt; urls, int maxDownloads)
      {
          var concurrentQueue = new ConcurrentQueue&lt;string&gt;();
  
          using (var semaphore = new SemaphoreSlim(maxDownloads))
          using (var httpClient = new HttpClient())
          {
              var tasks = urls.Select(async (url) =&gt;
              {
                  await semaphore.WaitAsync();
                  try
                  {
                      var data = await httpClient.GetStringAsync(url);
                      concurrentQueue.Enqueue(data);
                  }
                  finally
                  {
                      semaphore.Release();
                  }
              });
  
              await Task.WhenAll(tasks.ToArray());
          }
          return concurrentQueue.ToList();
      }
  </code></pre>
  
  <p>Questions</p>
  
  <ol>
  <li><p>configureAwait? Should I use</p>
  
  <p>var data = await httpClient.GetStringAsync(url).ConfigureAwait(false);</p></li>
  </ol>
  
  <p>var data = await httpClient.GetStringAsync(url);</p>
  
  <ol start="2">
  <li>ServicePointManager.DefaultConnectionLimit? Should I change this property as well?</li>
  </ol>