Send multiple WebRequest in Parallel.For

前端 未结 2 1854
孤街浪徒
孤街浪徒 2020-12-03 18:07

I want to send multiple WebRequest. I used a Parallel.For loop to do that but the loop runs once and the second time it gives error while getting r

2条回答
  •  攒了一身酷
    2020-12-03 18:18

    In addition to what Jim Mischel said about calling Close on the response, you also need to factor in that, by default, .NET limits an application to only two active HTTP connections per domain at once. To change this you can set System.Net.ServicePointManager.DefaultConnectionLimit programmatically or set the same thing via config using the configuration section.

提交回复
热议问题