Information générale
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Network:
Windows Server 2012 R2
>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
Précédent
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement