I have a created a C# windows service (Serv.exe) which is responsible for performing various tasks at the request of a running application (A.exe), some of these can take long periods of time and I need a way to know the status of my requested operation (running on the service) from the calling application (A.exe).

Currently the way I have started to implement this is by using the ControlService(handle, command, status) to send a custom command to the Service to perform the task being requested, I am also using QueryServiceStatus(handle, status) to get the status of the service from the SCM - so the basic plumbing is there and working.

Now the problem I have is, after sending my ControlService Command (which works fine) the calling application (A.exe) keeps running and, at a certain point, it needs to know if the task it requested of the service is finished or not - therefore I am looking for a way to Query the Service to report a custom status, not the standard running, stopped, pending, paused state of the actual service but the status of the request I made using the ControlService() request.

Is this at all possible?
Any help or hints would be immensily appreciated.


Yes, use IPC with named pipes! I do exactly the same thing.

I took this code and modified it to suit my needs:

Basically it sends commands with data that can talk to the service. You can send PING/PONG responses, tell it to set values, or query the status of the service.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.