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