What's effect to start a timer many times without any stop.

  • Thread starter Thread starter Boki
  • Start date Start date
B

Boki

Hi All,

I have a timer, if my data queue Q has data, the timer should start
work, if there is no data in Q, the timer should stop.

However, there is an event can fire timer to start.
Should I add a variable to know how many records inside Q ?

Ya, I think so, because timer should use for unknown events, check it
in a period.

Please advice any of your opinion.

Thanks!

Best regards,
Boki.
 
Timers have start and stop methods, and an elapsed event. You should not
need to start and stop the timer in the queue, but rather, in the elapsed
event handler check if the queue has data.
 
Boki said:
Hi All,

I have a timer, if my data queue Q has data, the timer should start
work, if there is no data in Q, the timer should stop.

For what? Either there is data in the queue or not when the elasped event
for the timer has fired.
However, there is an event can fire timer to start.
Should I add a variable to know how many records inside Q ?

Why should you do that? Why do you care? You start the timer, you leave it
started, the Elapsed event fires, and either that is data in the queue or
not.

If there is data in the queue when the timer's Elapsed event firers, the
data is there to be processed or there is no data in the queue. In either
case, the timer is not going back to sleep and counting the time again to
firer its Elapsed event, until the current processing in the Elapsed event
has completed, and the event is exited.
Ya, I think so, because timer should use for unknown events, check it
in a period.

For what? The timer checks in when the timer's Elasped event fires. Either
there is data in the queue to be processed or there is no data int the
queue. The only event you should be concerned about is what happens when the
Timer's Elasped event is fired and either there is data to be processed or
there is no data in the queue. The timer goes back into wait mode after the
Elapsed event processing has been completed and starts counting down again.
 
For what? Either there is data in the queue or not when the elasped event
for the timer has fired.




Why should you do that? Why do you care? You start the timer, you leave it
started, the Elapsed event fires, and either that is data in the queue or
not.

If there is data in the queue when the timer's Elapsed event firers, the
data is there to be processed or there is no data in the queue. In either
case, the timer is not going back to sleep and counting the time again to
firer its Elapsed event, until the current processing in the Elapsed event
has completed, and the event is exited.




For what? The timer checks in when the timer's Elasped event fires. Either
there is data in the queue to be processed or there is no data int the
queue. The only event you should be concerned about is what happens when the
Timer's Elasped event is fired and either there is data to be processed or
there is no data in the queue. The timer goes back into wait mode after the
Elapsed event processing has been completed and starts counting down again.

Hi

Because I think, if I already know there is no data in Q, I can save a
machine cycle/resource by disable the timer. That's my idea.

Thank you!
Boki.
 
If your queue is more often then not empty, then maybe a queue is not really
necessary. A queue is usually for times that you frequently expect some form
of backup.
 

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