Overlapping timer notificatoins?

  • Thread starter Thread starter Adam
  • Start date Start date
A

Adam

If I have a long task to do in my timer event, how can I properlystop
my timer again being notified again while I am still processing?

Thanks.

Adam
 
I am not sure I completely understand your question. See if this helps at
all.

You can have many timers running at once. If you use System.Timers you use
the Elapsed event to run your code in if you are using System.Windows.Forms
for your timers you use use use the Tick event.

If you want to make your code run without holding up the rest of your
application you can use System.Threading inside your Tick or Elapsed event
handler.

If you want to make your new thread pause so it doesn't use cpu for a while
you can do so with the thread.Sleep function.

I don't know much about what you are trying to do inside of the thread, but
please note that there are some things that don't play nice when in a
thread.

Hope this helps,
Nathan
 
Let me clarify with an extreme example. Say I only have 1 timer, set
to fire off at intervals of one minute.

Say in the first invocation, I do some database work which takes two
minutes to complete. During that, I'll get a second timer message (in
the same timer) which I don't want.

How can I stop this?

Thanks.
 
Back
Top