M
M
Maxim Romashko2017-05-23 22:13:58
C++ / C#
Maxim Romashko, 2017-05-23 22:13:58

25 c# requests are sent. How to fix?

while (true)
            {
                try
                {
                    HttpWebRequest rq = (HttpWebRequest)WebRequest.Create(url);
                    HttpWebResponse rp = (HttpWebResponse)rq.GetResponse();
                    if ((int)rp.StatusCode == 200)
                    {
                        successConnections++;
                        Console.WriteLine("Соединение прошло. Успешных: {0} Ошибок: {1}", successConnections, errors);
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine("Произошла ошибка с кодом: {0} \nИ со следующим сообщением: {1}", e.HResult, e.Message);
                    errors++;
                }
                Thread.Sleep(timeOut);
            }

25 requests are sent one by one. How to make that there would be no this timeout?
And does it depend on the fact that I send these requests to the local Apache?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
Oleg Pogrebnyak, 2017-05-23
@S0HardCore

How to make that there would be no this timeout?

Remove Thread.Sleep or set timeOut to 1.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question