xnet

C# - how to do multiple web requests at the same time

狂风中的少年 提交于 2019-11-29 16:10:16
问题 I wrote a code to check urls, however, ir works really slow.. I want to try to make it work on few urls at the same time, for example 10 urls or at least make it as fast as possible. my Code: Parallel.ForEach(urls, new ParallelOptions { MaxDegreeOfParallelism = 10 }, s => { try { using(HttpRequest httpRequest = new HttpRequest()) { httpRequest.UserAgent = "Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Firefox/52.0"; httpRequest.Cookies = new CookieDictionary(false); httpRequest