views:

51

answers:

3

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.

+5  A: 

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

JaredPar
I'm quite new to this, and all this looks rather overwhelming for just running one function. I don't doubt for a second that you are correct and know exactly what you are talking about, but isn't there an easier way using the tcp connection I already have?
Alex Godbehere
@Alex if you have an existing TCP connection and are already sending data back and forth then you could just invent a message protocal. Say if the first byte is 0 then do what you're already doing else if the byte is 1 call this specific function, etc ...
JaredPar
Ah, that makes sense. I'll give that a go, thanks.
Alex Godbehere
A: 

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

John K
It's not web based but I have it working now. 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. Thanks for you're input though.
Alex Godbehere
+1  A: 

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.

Alex Godbehere