Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Using a timer
Message
From
19/07/2016 09:05:57
 
 
To
19/07/2016 06:39:26
Luis Santos
Biglevel-Soluções Informáticas, Lda
Portugal
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows 10
Network:
Windows Server 2012 R2
Database:
MS SQL Server
Application:
Desktop
Miscellaneous
Thread ID:
01637566
Message ID:
01638511
Views:
78
>Hello Tamar
>
>Thanks for your exemple, but i need something a little diferente:
>
>I need to trigger the timer each day (1 time per day) on specific hour without destroying the timer, so the following day on the same time the timer will go trigger again.
>for exemple building a simple form with a textbox for the hour that i was pretend to trigger the timer.
>if the hour specify on my textbox is equal to my system hour then I trigger the timer and run my procedure to do something.
>in your example the timer is quit.
>Can you help about how to solve my problem.
>
>Sorry, but i try several script without sucess.

That really sounds like a job for Windows Scheduler, not a VFP timer. One big reason is that your application has to be running for the timer to do the job.

But if you insist on using a VFP timer, I'd subclass timer and add a property to hold the specific time you want to do the task and a property to hold the datetime when the task was last performed. I'd then set the Interval to as large a value as you're comfortable with. That is, if you must do the task within 1 minute of the specified hour, then say 30 second. If it's okay to do it within 5 minutes of the specified hour, I'd set it for maybe 2 minutes. Etc. The less often the timer fires, the better, since the timer will slow your application down.

Then, in the Timer method, I'd first check whether I'd already done the task today (by looking at the last time it was done property). If not, I'd compare the current time to the desired time to figure out whether it's time to do it. When it is time, I'd call a method to do the task, and I'd set the last time it was done property.

Hope this makes sense.

Tamar
Previous
Reply
Map
View

Click here to load this message in the networking platform