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.
"Niron kag" <Ni******@discussions.microsoft.comwrote in message
news:07**********************************@microsof t.com...
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.