I have read quite a bit on this topic and am pretty sure that the correct method would be to use invoke, but I can't wrap my mind around how to call it (been working with c# for about a week).

I have a HandleCommand method in the MainForm class that will be passed a string telling the method what to update.

Around line 230 in the ChatServer class, I want to tell my gui to update and add a new user to the textbox by calling HandleCommand around line 250 in the MainForm class. A string must be passed as a parameter to HandleCommand; any string will do for now. How can I do this?

Recommended Answers

All 4 Replies

>A string must be passed as a parameter to HandleCommand; any string will do for now.

Think about backgroundworker.

As I said, I have only been using c# for about a week. I took a look at some of the background worker examples on google, but they were over my head. Can you provide me with an easy example (relating to my project if possible). Thanks for your time.

I am sorry, but I don't understand what is going on in the thread. My problem is that I want to call the HandleCommand method from the static method AddUser. I am having trouble with this because I need a reference to MainForm so I have access to the form's controls.
From what I can see in the thread you pointed me to, everything is in a static context which doesn't help me (at least I don't think it does). Do you have any code or explanation relating to my code so I can see exactly how it relates to my script? I would really appreciate it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.