Click here to Skip to main content
16,019,768 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have an application that reads a tag and then process according to it. Currently I have set the timer to tick for per second and the function(includes Image shown from database accordingly) is called on that tick event.
But now I want to manage that tick event on another tick event i.e for count down timer. I want the first timer to tick as it is but to add a new timer to maintain count down if the first timer reads the same tag repeatedly and if time elapses more than 2 minutes then clear the image from the form. And if before that the first timer tick gets a new tag than replace the previous image from the current one...

Now the problem is coming to manage both timer with current requirements.
Any clue, help, guide any thing in this regard will be heartly accepted. And thanks in advance.
Posted
Comments
BillWoodruff 16-Dec-13 6:38am    
Under what circumstances would a tag be processed more than once ?

If a tag is repeated, isn't there some reason like, for example, you use the same graphic file in more than one place on your Form ? I can imagine a scenario where you want to read-in and "cache" images in some way ... like making them into a Resource ... and then re-use them multiple times: is that what's going on here ?

The other timer then is a sort of "Timeout watcher". It works something like this:

1) Start timeoutTimer.

2) Let your firstTimer work as usual,

3) Plus save a copy of the tag in some member variable.

4) Within firstTimer's Tick event, let it check if tag has changed and if so, reset timeoutTimer. So whenever firstTimer ticks, it postpones timeoutTimer's Tick. Just if firstTimer fails to do something within timeoutTimer's interval, its event handler is called.

5) On timeoutTimer's Tick event, do whatever the timeout requires to be done.
 
Share this answer
 
I would use just one timer and a state machine[^] inside the tick event handler.
 
Share this answer
 
v2
Comments
BillWoodruff 16-Dec-13 6:33am    
Correct link is:

http://en.wikipedia.org/wiki/Finite-state_machine

But, I do not think this is an appropriate referral for a relative newcomer to .NET and, probably, programming.
CPallini 16-Dec-13 6:38am    
Thank you, now the link is fixed.
Sooner or later a programmer has to know that, in my opinion.
kool15th 18-Dec-13 0:40am    
thanks...I will Try It for sure.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900