Thread is not something that is being called continuously, your code in the thread block need to be called continuously, since your thread is responsible of calling ContinueRcv
the thread ends with the end of this method,
If you want to continuously receive the data from Stream
you need to call StreamReader's ReadLine() in some infinite loop,
void ContinueRcv(object obj)
{
TcpClient client = (TcpClient)obj;
StreamReader sr = new StreamReader(client.GetStream());
while (true)
{
if ( !connection ) { // when connection closed, abort, terminated
break;
}
msg = sr.ReadLine();
textBox1.Invoke(new MethodInvoker(delegate()
{
textBox1.Text += msg + Environment.NewLine;
}));
}
}
Remember to break the loop when connection closed,