streamreader hangs out

T

Tunga Torgal

hi,

I have the following code. It hangs out and waits infinitely on
StreamReader.Read method.
any ideas?
thanks in advance...

WebRequest myHttpWebRequest = WebRequest.Create(myUri);

myResponse = (HttpWebResponse)myHttpWebRequest.GetResponse();



Stream ReceiveStream = myResponse.GetResponseStream();


Encoding encode = System.Text.Encoding.GetEncoding(1254);

StreamReader sr = new StreamReader(ReceiveStream, encode);

Char[] read = new Char[1024];

int count = sr.Read(read, 0, 1024);

StringBuilder strHTML = new StringBuilder();

while (count > 0 && strHTML.Length <= MAX_SIZE)

{

String str = new String(read, 0, count);

strHTML.Append(str);

count = sr.Read(read, 0, 1024); ----> hangs out here....

}

sr.Close();
 
J

Joerg Jooss

Tunga said:
hi,

I have the following code. It hangs out and waits infinitely on
StreamReader.Read method. any ideas?
thanks in advance...

WebRequest myHttpWebRequest = WebRequest.Create(myUri);

myResponse = (HttpWebResponse)myHttpWebRequest.GetResponse();



Stream ReceiveStream = myResponse.GetResponseStream();


Encoding encode = System.Text.Encoding.GetEncoding(1254);

StreamReader sr = new StreamReader(ReceiveStream, encode);

Char[] read = new Char[1024];

int count = sr.Read(read, 0, 1024);

StringBuilder strHTML = new StringBuilder();

while (count > 0 && strHTML.Length <= MAX_SIZE)

{

String str = new String(read, 0, count);

strHTML.Append(str);

count = sr.Read(read, 0, 1024); ----> hangs out here....

}

sr.Close();

Did you try to read the raw stream completely and decode the bytes
later?


Cheers,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top