By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,610 Members | 1,989 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,610 IT Pros & Developers. It's quick & easy.

Solution for the Error : The service did not respond to the Stop call in a timely fashion

P: n/a
Hi,
I am writing a service which takes a long time to stop after the OnStop
call is given by the Services Snap-in. The problem is I cannot cut down on
the time that it takes to Stop. The Service snap-in gives me the error
saying that the service did not respond to the Stop call in a timely
fashion. So is there any method by which I can get around this problem.

Thanks
Prasad


Sep 28 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Sure. You can run the job in a separate thread than the main execution
thread. Calling Stop will send a message to the child thread instructing it
to stop itself, and the main execution thread can continue processing. This
is what is called an "asynchronous" operation, as opposed to a "blocking"
operation.

For example, I have a service that runs a certain kind of job. The service
doesn't actually do the job; an instance of a class that exists in the
service runs the job. The OnStart method of the Service calls the class's
"Start" method, which spawns a chilc thread executing the "Run" method of
the class. The OnStop method of the service calls the class's "Stop" method,
which sets a property in the class, which the child thread looks at from
time to time. The "Stop" method then continues on its way. The child thread
looks at the property, sees that it needs to stop, and stops itself.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Big things are made up of
lots of little things.

"Prasad" <ek*********@yahoo.co.uk> wrote in message
news:um**************@TK2MSFTNGP11.phx.gbl...
Hi,
I am writing a service which takes a long time to stop after the OnStop
call is given by the Services Snap-in. The problem is I cannot cut down on
the time that it takes to Stop. The Service snap-in gives me the error
saying that the service did not respond to the Stop call in a timely
fashion. So is there any method by which I can get around this problem.

Thanks
Prasad

Sep 28 '05 #2

P: n/a
Thnx man.
But I had done the same thing what u suggested but the problem is the
Service Snap - in shows that the service has stopped but there is still the
background thread running which means that the process is still running. I
dont want this to happen. I want to negotiate with the SCM on the time and
it should show that the Service stopped if the process is really completed.

Thanks
Prasad

"Kevin Spencer" <ke***@DIESPAMMERSDIEtakempis.com> wrote in message
news:uX**************@TK2MSFTNGP09.phx.gbl...
Sure. You can run the job in a separate thread than the main execution
thread. Calling Stop will send a message to the child thread instructing
it to stop itself, and the main execution thread can continue processing.
This is what is called an "asynchronous" operation, as opposed to a
"blocking" operation.

For example, I have a service that runs a certain kind of job. The service
doesn't actually do the job; an instance of a class that exists in the
service runs the job. The OnStart method of the Service calls the class's
"Start" method, which spawns a chilc thread executing the "Run" method of
the class. The OnStop method of the service calls the class's "Stop"
method, which sets a property in the class, which the child thread looks
at from time to time. The "Stop" method then continues on its way. The
child thread looks at the property, sees that it needs to stop, and stops
itself.

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
Big things are made up of
lots of little things.

"Prasad" <ek*********@yahoo.co.uk> wrote in message
news:um**************@TK2MSFTNGP11.phx.gbl...
Hi,
I am writing a service which takes a long time to stop after the
OnStop
call is given by the Services Snap-in. The problem is I cannot cut down
on
the time that it takes to Stop. The Service snap-in gives me the error
saying that the service did not respond to the Stop call in a timely
fashion. So is there any method by which I can get around this problem.

Thanks
Prasad


Sep 29 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.