hello again!
first of all since you are listening your connection from the thread you will have to throw acception from your client. and your code in your backgroun thread probably will look like this
public delegate void PassMessage(string str);
public event PassMessage MessageReceived;
..........
while (true)
{
if (stream.DataAvailable)
MessageReceived(getMessage());
}
which will end with an error so like you have to call Message Received from the main thread like this
public delegate void PassMessage(string str);
public event PassMessage MessageReceived;
..........
while (true)
{
if (stream.DataAvailable){
PassMessage p = new PassMessage(MessageReceived);
Form1.Invoke(p,new Object[] {getMessage()}
}
}
which does the same thing, only does it on the thread which Form1 belongs to. I don't know if this is helping you but there is also various examples about Invoke Method. you might wanna check them out too.. I needed the same functions couple days ago and google it.