Question

In .NET, the ServiceController class allows you to send a custom command to a service using the ExecuteCommand method.

I would like to be able to query the service for its status (a custom notion of status, not the 'Started/Stopped' variety). I was hoping it would be straightforward to make a call to the service using something similar to ExecuteCommand and get a return value indicating the status. Is there something in ServiceController that would enable me to do this?

Assuming not, I guess I have to use some kind of external inter-process communication technique (e.g. service writes its status to a database, or to a message queue). What would you recommend for simplicity?

Was it helpful?

Solution

There certainly isn't a way in ServiceController. Leaving WCF as presumably the best option. Tutorials here: http://www.switchonthecode.com/tutorials/wcf-tutorial-basic-interprocess-communication

OTHER TIPS

Windows offers many means of inter process communication (IPC). @David is right, ServiceControllers cannot perform this action, and he was good to point you to WCF, its a foundation that comes readymade with IPC capabilities. Using IPC you could coordinate your service and your application after an ExecuteCommand call.

If your not looking to go as far as WCF you could implement a pipe (anonymous pipe seems right for this case) or use windows sockets.

Check out this link from MSDN on IPC, it's a great trailhead for the multiple avenues you could take.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top