Controlling a Windows Service
I have a windows service that synchs. local data with that on the server. In the onStart() method I start a separate thread and call the synch. method so that the Service starts running.
On the other hand I've a Synch. controlling program, i.e. a desktop app. having one form and a systray icon, much like the Sql Server agent for controlling its service. The service and this program are separate from each other and in the controlling program I simply get to my service by first getting all the services on that system and then getting my service by its name. I can then stop it, start it etc. No problem.
In my synch. service, during synch. there are certain stable points where I can pause the service without affecting the synch., if the service is at that point, I need to give the user through the control program authority to pause it, the problem is how the controlling program know that service is at a stable point or not. I tried, to do it by setting
this.CanPauseandContinue = true;
at those stable points in the service, and then again setting it to false when service is not stable, but the service gave error that these properties cannot be changed while the service is running.
Is there a way that I can set a variable in the service at stable points to true, and then access it in the outside controlling program to enable the pause option?
Any help would be very appreciated!!
Thanks & Regards,