I have a server and a client program, and they communicate as expected. The only thing is, I have a combo box on the client program, and when this combo box is changed, I want it to call a function on the server program. How would I go about this? I've thought about it for a while, and just can't seem to get it to work.
You'll need to establish a communication path between the two programs and send a message in the event of the combo box change. There are many possible solutions out but a couple of the more popular methods of cross process communication in .Net are
- WCF
- Remoting
- Named Pipes
My personal choice would be to use WCF. I find it to be less connected and easier to use than Remoting and there are tons of tutorials available on the subject
If your application is at all web based or has access to the HTTP protocol, another option I would suggest for the client/server model in addition to the excellent ones already suggested by Jared Par, is to leverage HTTP through a web service (or similar) for communication.
For example
- ASP.NET web services.
- MVC using Restful architecture.
- or even jQuery/AJAX on the front end (or a similar library) if your presentation layer is web based.
I tried JaredPar's solution by getting the client to send a message that started with "6", and get the server to monitor all incoming messages for a message that started with "6". If one did, then it called the function.