How to limit the amount of concurrent async I/O operations?

前端 未结 14 2502
遇见更好的自我
遇见更好的自我 2020-11-22 01:27
// let\'s say there is a list of 1000+ URLs
string[] urls = { \"http://google.com\", \"http://yahoo.com\", ... };

// now let\'s send HTTP requests to each of these          


        
14条回答
  •  时光说笑
    2020-11-22 02:17

    this is not good practice as it changes a global variable. it is also not a general solution for async. but it is easy for all instances of HttpClient, if that's all you're after. you can simply try:

    System.Net.ServicePointManager.DefaultConnectionLimit = 20;
    

提交回复
热议问题