This may not be the best way to do this, but it should work ...
You can run your TCP listener code in a new thread when the program starts ... This way, you listen to the TCP code when the user interface is disconnected from others. When something happens in the TCP stream, it will have to signal the user interface stream with some event or event queue.
Now, from the point of view of updating the WinForms object, when something is received, I believe that only the thread that created the WinForms control can update the controls. Therefore, you will have to consider this as well.
This is a problem that I struggled with before as well ... In my current project I am doing what I mentioned above ... however there is a bit of thread synchronization to make it work.
Polaris878
source share