Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Timer enabled
Message
From
17/05/2019 07:56:25
 
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP SP2
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01545860
Message ID:
01668677
Views:
67
After almost 7 years I had the similar situation and was unsure about the functionality, searched here and rediscovered this thread. None of the replies made clear how ENABLED really relates to RESET and INTERVAL. So, here's my answer after having done a test.

The basic principle for the timer's interval is NOT so much 'how long', but rather 'HOW OFTEN'. Suppose the interval is 1 second, then the timer() event will be visited 10 times in 10 seconds. Sure, if the code in the event takes less than 1 second, then it will be visited each second. HOWEVER, if the code in the Timer() event takes LONGER than 1 second, than a STACK will be used and ALL visits will be done AFTER the timer event finished.

Think of the consequence. Suppose on the first visit the event takes 10 seconds, than immediately thereafter the 2nd till 10th visit take place. They were POSTPONED, NOT CANCELED.

To prevent this overload (or even troublesome amount) of events, it is necessary to set ENABLED to FALSE at the TOP in the timer event and to set it to TRUE at the end. Or better, to set it to False at the top AFTER an IF that indicates that a time consuming action is about to occur. And accordingly set it to True just before the ENDIF.

A trade-off of setting ENABLED to TRUE is that it works like a timer.RESET(). This is not documented, but it is nevertheless true. The consequence is that there's a fundamental difference between these ways of setting to true:
timer1.enabled = .T.
if not timer1.enabled
    timer1.enabled = .T.
endif
>I have a container with a TIMER that has the INTERVAL set to 1 minute. It is ENABLED (or disabled) in the REFRESH of the container. That refresh is visited each 10 seconds.
>
>I noticed that the timer did no longer fire each minute if its ENABLED.property is explicitly set to True each 10 seconds.
>
>It does fire if I only set the ENABLED property if its new value differs from the current value.
>
>It seems as though the ENABLED property acts as some sort of RESET().
>
>Who can explain this? Or do I miss a clue?
Groet,
Peter de Valença

Constructive frustration is the breeding ground of genius.
If there’s no willingness to moderate for the sake of good debate, then I have no willingness to debate at all.
Let's develop superb standards that will end the holy wars.
"There are three types of people: Alphas and Betas", said the beta decisively.
If you find this message rude or offensive or stupid, please take a step away from the keyboard and try to think calmly about an eventual a possible alternative explanation of my message.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform