There is a method Get2
static void Get2(object x) { using (var request = new HttpRequest()) { double n = Convert.ToDouble(x); request.UserAgent = Http.ChromeUserAgent(); request.Cookies = cookies; request.AllowAutoRedirect = false; var res = request.Get("http://ru.stackoverflow.com"); Console.WriteLine(x); } } I call it using a thread pool (you need to call the method several times and as quickly as possible)
num = 1000; numto = 10000; while (num < numto) { for (int i = 0; i < 500; i++) { ThreadPool.QueueUserWorkItem(new WaitCallback(Get2), num); num++; } } while runs in less than a second, but in the method it reaches the request getter and then Console.WriteLine(x); does not want to go Console.WriteLine(x); - does not output, looked with a sniffer, het request does not pass. But, if you call a method using Thread
for (int i = 0; i < 500; i++) { Thread myThread = new Thread(new ParameterizedThreadStart(Get2)); myThread.Start(num); num++; } That all works, the request passes. The only problem is that this method spends much more time (because the threads are created, and not ready-made and so on). Can you tell me how to solve the problem with the thread pool?
UPD: because it did not find a solution to this problem, instead of xNEt I used the standard HttpWebRequest and everything was decided