Send multiple WebRequest in Parallel.For

前端 未结 2 1853
孤街浪徒
孤街浪徒 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 <system.net><connectionManagement> configuration section.

    0 讨论(0)
  • 2020-12-03 18:22

    Most likely the problem is that you need to call response.Close() after you're done processing the response.

    0 讨论(0)
提交回复
热议问题