Stop Windows service while timer_event running

  • Thread starter Thread starter bob biris
  • Start date Start date
B

bob biris

I have a windows service using a timer to fire events at regular
intervals.

When the time elapsed the timer starts a process. This process can
take a long time and it seems that if I stop the service it also stops
the process. Is there a way to have the service to wait and stop when
the process is finished?

Thanks

Robert
 
Hi Robert
any process that is intiated from your service will run with in the same
proccess space of your sevice and it will be terminated whenever your
service stops . you don't want that to happend, in this case you need to
disable the stopping of your service , no user can stop your service, you
can do so by settig the can stop property of your service to false CanStop.
Then you add a custom action to your service on which you will
wait for the other proccess " that was intiated by the timer" to finish
then you fire the close event from with in your code..... hope that would
help
 
Thanks Mohamed,

What is the best way to fire the close event. DO you have an example of code?

Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top