I've searched a ton, but I can't seem find anything relating to my specific problem.
I want to be able to update my MainUI form from another class (SocketListener) and within that I have a thread that handles the networking (clientThread). Right now I can run simple outputs from the networking thread such as writing to the debugger output and creating a MessageBox.
But what I really want to do is be able to invoke code from the clientThread that will do things on my MainUI instance. How can I do this?
Also, if anyone wants specific portions of the code then I can post it to help give you a better understanding of what I'm asking.
Best regards!
Best Answer
Check the
InvokeRequired
of theControl
class, and if it's true, then call theInvoke
and pass in a delegate (usually an anonymous method) that does what you want to do on the client's thread.Example: