Reputation: 13582
I have a windows services project consisting of two services, service1 and service2. How can we communicate between the two services? For example, how can we have have service2 started by service1? Can I use the ServiceController class to do this? What would you suggest to do this?
Upvotes: 2
Views: 2607
Reputation: 670
The ServiceController class includes an ExecuteCommand methods that takes an int. Your two services could therefore communicate by sending ExecuteCommand messages to each other if you can get away with very limited parameters.
However, as the other poster comments, WCF may be a better answer. You can create named pipes or use HTTP between the two services. Two good tutorial pages can be found below.
Basic WCF Tutorial with examples
More complex WCF, if you wanted to 'fake' delegates for example
Hope that helps.
Upvotes: 7
Reputation: 50712
If "comunication" you mean just to start and stop Service2, than yes, ServiceController
should be used.
If you need other type of comunication, like sending some data from one to another,than ServiceController
will not help, you should use WCF
Hope this helps
Upvotes: 6