When a service is told to stop, I believe it has 30 seconds before the
Service Control Manager abandons the service.
What you need to do is call the SetServiceStatus API function through
the P/Invoke layer, using the value returned from the ServiceHandle property
(it is the handle to the service which you can pass to the SetServiceStatus
function).
In your OnStop method, you would have to wait a little bit, check to see
if the update completed, then call SetServiceStatus, indicating that you are
waiting (incrementing the dwCheckPoint field of the SERVICE_STATUS
structure, so that your service knows you are doing something).
I can't recall completely, but I think there is an absolute value that
windows will wait for the service to wait, even in light of the calls to
SetServiceStatus, which if exceeded, will cause the service to be
terminated, so you might want to make sure your update completes in a timely
manner in this case.
--
- Nicholas Paldino [.NET/C# MVP]
-
mv*@spam.guard.caspershouse.com
"archana" <tr**************@yahoo.comwrote in message
news:11**********************@l70g2000hse.googlegr oups.com...
Hi all,
thanks for replies.
I used same thing. I am getting following error
Could not stop the 'MyTestService' service on Local Computer.
Error 1053: The service did not respond to the start or
control request in a timely fashion.
Can anyone tell what to do to solve this problem. Becase its major
problem and on service i can't restart server everytime if this error
occurs. And i want proper way to stop service.
thanks.