Answer the question
In order to leave comments, you need to log in
Why is the second thread "blocked" when trying to http-request?
Hello. There is a method for sending requests:
public static XDocument _request(string Url)
{
WebRequest Request = WebRequest.Create(Url);
Stream XmlStream = Request.GetResponse().GetResponseStream();
return XDocument.Load(XmlStream);
}
foreach (string Link in Links)
{
TimerCallback RSSCallback = new TimerCallback(ReadRSS);
Timer Timer = new Timer(Test, Link, 0, 3000);
}
public static void Test(object obj)
{
string Url = (string)obj;
Console.WriteLine($"Запрос на {Url}");
RSS._request(Url);
}
return XDocument.Load(XmlStream)
. If you remove it, then all requests are normally sent to both resources without any problems.
Answer the question
In order to leave comments, you need to log in
I do not really understand why all these Timer and TimerCallback.
If you just need to run several queries in parallel, I suggest this code:
TimerCallback RSSCallback = new TimerCallback(ReadRSS);
Timer Timer = new Timer(Test, Link, 0, 3000);
new Task(Test, Link).Start();
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question