Stop winodw service from itself

Sandeep Singhvi

New member
Joined
Aug 17, 2005
Messages
4
Programming Experience
1-3
Hello friends,

I've created one window service which performs particular task at regular inverval. I am using one desktop application using Service Controller to start the service. So its OnStart method will be called. Now from this method one private proceudre is called which runs at regular interval and checks for files to be uploaded on FTP if it exists. So if there are no files to upload then I want to stop that service from this procedure (From Window Service itself). I've tried using WaitForStatus method of Service Controller. Is it possible to use Service Controller to stop the same service which is running? Actually, when I am calling Start method using Service Controller, its stop method is called whereas service still is not started. So it is going in confused state and I've to restart my PC.

How can I achieve this functionality? Awaiting for your replies.

Thanks and regards.
 
Back
Top