Windows service management

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I run a windows service, every 30 minutes.
The tasks in the service can take one time 30 minutes, one time 1 hour, and
one time 10 minutes or less, it depends on the data that the user supplies to
the system.
How can I prevent a situation that a new cycle of the service start before
the previous completes?

Thanks in advance.
 
Assuming that the service has its own built-in timer that runs the job, you
can put a conditional statement in the timer's Elapsed event handler, which
checks to see if a job is already running, and stops the timer if it is. It
can then start a new job and reset the timer as soon as the job is complete.
The way it knows whether to let the timer's Elapsed event handler start the
job, or whether the job should be restarted immediately, you just check the
Timer's Enabled property. If it is Enabled, the job did not extend beyond
the interval and stop it; therefore it does not have to restart itself. If
it is disabled, the job extended beyond the interval, stopping the timer in
the process, and it needs to restart itself.

--
HTH,

Kevin Spencer
Microsoft MVP
Chicken Salad Surgery

Accept the Unexpected.
 

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