makinmg sure Timer doesn't execute again while running...

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

Guest

I have several procedures that are executed when the Timer.Tick event is run.
How can I make sure that those procedures are not executed again (by the
Tick event) if the previously-called procedures (also called by the same Tick
event) are still running?
Is it possible to condition it using a bool? For example, just before
running the first procedure activated by the Timer, bool iSComplete will
equal false. When the Timer is run again after X seconds, it'll check
iSComplete. If iSComplete is false, then it won't run again. If not, it'll
run.
The problem is that I tried this, but it displayed some erratic behavior. I
think it has to do with the threading.

Thanks.
 
If I understand the problem correctly...
All you have to do (and should always do to avoid re-entrance) is
disable the timer when the procedure is entered and re-enable it when
exiting. You should also follow this model when executing button click event
methods to avoid the user clicking the button while the button code is
executing.

Gregory McCallum, MCSD
(e-mail address removed)
 
Back
Top