Click here to Skip to main content
15,888,020 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have several buttons that are mef plugin's to a separate application, and are displayed by that apps' view model. I need to also be able to control the status and toggle of those buttons from a windows service. Possible, and where can I look? Using .Net 4.0
Posted

1 solution

The question is way too vague to give the exact advice. You did not describe your existing architecture and what have you tried. You did not explain what could be your problem.

But the idea could be this: you should remember that your windows service works even if there is no a desktop, so none of the UI applications even exist. So, the collaboration you need should be established by the initiative of your UI application, which is inline with the concept of "client-server".

You have to create some network or, more appropriately, IPC service in your windows service. It could be done directly using sockets or named pipes, or, on a higher level, using "classic" remoting or WCF hosted in your windows service. The UI application should be able to connect to the service (presumably, on their startop and disconnect before their termination) and subscribe to some service events (whatever you need to introduce). In the handlers of those events, the UI application can change the states of the buttons or whatever you need to change. The server should remain agnostic of the UI behavior. This way, you would support loose coupling and avoid strong coupling, which is very important in this case.

Please see also:
http://en.wikipedia.org/wiki/Loose_coupling[^],
http://en.wikipedia.org/wiki/Coupling_(computer_science)[^].

—SA
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900