Talk to windows service
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. installi开发者_如何学运维ng 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?
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.
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.
精彩评论