A question about NetworkStream read & write operation inside threads



Hi,

try
{
int x = ns.Read(readbuffer, 0, readbuffer.Length);
}
catch (System.IO.IOException ioexception)
{
UINotifications.ServerMessageDisplay(ioexception.ToString( ));
}
"ns" is an instance of NetworkStream got by calling tcpclient's GetStream()
function.
"UINotifications" is my own calss.

this code is running is a seperate thread and as can be seen it will be in a
blocking state as it executes the "read" function. My question is that while
it is in this blocking state, I want to perform a write operation. Would
that be valid operation? And how do I make the write operation execute in
this same thread (isnt it blocked)? Will I have to take a reference of the
networkstream obj and use it from another thread to write to the stream? But
I dont want to write from another thread. Its kind of confusing me.
Any guidence greatly appriciated !

Thanks,

-Ab.


.