StreamReader.ReadLine - It waits for a message?

ThePentiumGuy

Well-known member
Joined
May 21, 2003
Messages
1,113
Location
Boston, Massachusetts
Hey guys,
When I read from a stream (TCPClient.GetStream) using StreamReader.ReadLine, it (obviously) waits until it receives some text and then it continues.

Is there any way to do something like:
Streamreader.ReadLineButStopIfTheresNothingToRead ?

My chat program is going really well, just the server seems to hang on this line, and I cant really... do anything else (ex: AddUserWhenTheyConnect()).

-The Pentium Guy
 
TPG, if you arent using asynchronous methods or threads, then it will stop on that statement and wait until someone does connect. Are you using it and it still stops there?
 
I dont know what asynchronous means, but all I know is that I do not wish for it to stop there, I just want to make it so that when the server receives a message - itll process it, and franky I dont know where to start :P, besides checking in an infinate loop whether the message it received was blank or not (it becomes blank anways unless it receives a message, because that ReadLine line runs in its own thread... whch seems to confuse me becuase if its running in its own thread then why is it not going to the AddClient sub?)

-The Pentium Guy
 
Ill upload some code (as an edit) to this post later when I am at my work pc. Its the help that I received from HJB on the same toppic.
 

Attachments

Last edited by a moderator:
Back
Top