PC SOFT

FORUMS PROFESSIONNELS
WINDEVWEBDEV et WINDEV Mobile

Accueil → WINDEV 2024 → Execute procedure on particular time
Execute procedure on particular time
Débuté par anahoret3, 30 aoû. 2023 19:02 - 3 réponses
Posté le 30 août 2023 - 19:02
Greetings,

I have a combo box time field: 07:00:00(HHMMSS) which means I want to execute something at this time each morning.
Application is always running.
How to achieve it ?

COMBO_TimeSync.Value = TimeToString(TimeSys,"HHMMSS")

Thanks a lot !
Posté le 31 août 2023 - 21:00
Hi Vlad

There are a couple of ways that spring to mind.

One would be to start a new thread when you start your application. In that procedure, have a continuous loop that checks the current time against the time set in the combo.

ThreadExecute("TimedProc",threadNormal,TimedProc)



PROCEDURE TimedProc()
LOOP
IF Now() = 19474500 THEN
//Execute timed code
END
END

Although this will not interupt your normal program, it will greatly put a strain on your CPU.

The second option would be that when you start your app, calculate the time difference between now and the combo time and set up a timer with that calculation. Once the timer has run, you would need to reset the timer for the next day. For this, I would recomend that you again calculate the time difference, otherwise if your procedure takes a few seconds to execute, then the time will slip each day.

Hope this is of some use
Simon Phillips
Posté le 02 septembre 2023 - 16:10
Hi Vlad

I was presuming that you were needing to run the process at exactly the time selected to the second. If you are happy to run the process during the selected minute, then simply set up a timer to run every 60 seconds. In that called procedure, check that the hour and minute selected match the current time and if not return without doing anything.

Hope this helps
Regards
Simon Phillips
Posté le 04 septembre 2023 - 08:27
Thanks a lot Simon!