2

i am not sure what my title should be, so i used the word "Talk".

I have created a window service, that is running perfect. installing and everything.

BUT. i need a system tray running, and a program that can call function inside the windows service.

Like, when a user click on "Get Clicked" it will turn something inside the windows service.

i am not sure how can i do.. i have come in to thinking for some ways that are really stuipd.

like changing a text and then the windows service reads it for commands. i think its very idiot way. any other way that you know of that i can talk to the window sservice?

its seems like everybody answering "WCF". but, wouldnt it be simple if only open a port to TCP on port 25555 or something. and only read writeing? like words. "Now, Later". and do functions with it? i thnink it will work. dont you?

Alon M
  • 1,583
  • 7
  • 30
  • 44
  • possible duplicate of [How to communicate with a windows service?](http://stackoverflow.com/questions/4451216/how-to-communicate-with-a-windows-service) – Davide Piras Sep 01 '11 at 08:39

2 Answers2

5

in the past .NET remoting was often used for this, nowadays you can use WCF which performs way better.

Just host a small WCF service in your Windows Service and make the UI application (like tray icon manager) to call those exposed WCF end points to communicate with the service.

You do not need IIS or anything else, if you use netTcp binding or namedPipes it would work smooth.

Davide Piras
  • 43,984
  • 10
  • 98
  • 147
  • Any guild on how to use WCF service? how to put it into my project and how to use it? THANKS MAN :) – Alon M Sep 01 '11 at 08:23
  • plenty of samples man, here in SO and in msdn.... http://msdn.microsoft.com/en-us/library/ms733069.aspx – Davide Piras Sep 01 '11 at 08:32
  • i cant understand anything fromt here. and other website plesae :)? – Alon M Sep 01 '11 at 08:33
  • http://stackoverflow.com/questions/84860/how-to-communicate-with-a-windows-service-from-an-application-that-interacts-with – Davide Piras Sep 01 '11 at 08:38
  • also have a look at this: http://stackoverflow.com/questions/4451216/how-to-communicate-with-a-windows-service – Davide Piras Sep 01 '11 at 08:39
  • Well, i was unable to understand ANYTHING from this. i am very sorry. so i am editing my qustion so you can have a look. 2 min.. – Alon M Sep 01 '11 at 08:44
1

If you don't like to go with WCF or any service. You can go DB way (or filesystem).Write command and serialize the object (if required) and store in any file or db. Modify your service to watch the location and read and execute command. Deserialize the object if required. You can use shared object (memory) to achive this. Using WCF will be more flexibility and extensible though.

hungryMind
  • 6,931
  • 4
  • 29
  • 45
  • Yes that will also work. But why to go at low level? Are you expecting commandSender and commandHandler on different machine? – hungryMind Sep 01 '11 at 11:48
  • "Low Levels" Means not a good way? if so. because there is no good guild how to use WCF. i didnt find ANYTHING. and i need that program runing in about 5 days. so if tcp is my way to do so, what chosed do i got? – Alon M Sep 01 '11 at 11:55
  • Depends how complicated and no of commands, your application will implement, but if I assume 20 commands, you can definately implement in 2-3 days . Here is link to create simple wcf http://weblogs.asp.net/ralfw/archive/2007/04/14/a-truely-simple-example-to-get-started-with-wcf.aspx – hungryMind Sep 01 '11 at 13:41