I'm trying to create an application that executes multiple threads and in that thread there will be a connection to a website. I keep reading the website (as it keeps sending information).
The problem is that only one thread seems to be able to keep reading from the website, the other threads looks like there are not able to read the stream.When I set an breakpoint the working threads hit it but the others don't. So I look in Threads overview window and see the other thread there and as location it has 'In a sleep, wait or join'. It also doesn't come in one of the try catch blocks.
I don't know how to solve this, thanks in advance for your help.
HttpWebRequest request = (HttpWebRequest) HttpWebRequest.Create(domain);
request.Credentials = new NetworkCredential(Username, Password);
HttpWebResponse response = (HttpWebResponse) request.GetResponse();
using (response)
{
Stream resStream = response.GetResponseStream();
using (resStream)
{
int count;
do
{
count = resStream.Read(buf, 0, buf.Length);
// make sure we read some data);
if (count != 0)
{
string tempString = Encoding.ASCII.GetString(buf, 0, count);
QueueResponse(tempString);
}
catch (Exception e)
{
Console.WriteLine("Exception occured");
}
Thread.Sleep(1000);
} while (count > 0);
}
}