PC SOFT

FOROS PROFESIONALES
WINDEVWEBDEV y WINDEV Mobile

Inicio → WINDEV 2024 → WD21 - Timer
WD21 - Timer
Iniciado por guest, 13,sep. 2017 19:38 - 10 respuestas
Publicado el 13,septiembre 2017 - 19:38
Hi All

A bit of a dumb question I guess. I am wanting to set a procedure to run at or soonest after a specific time every day. Any ideas?

Cheers
André
Publicado el 13,septiembre 2017 - 20:59
Andre

FYI: I have a daily batch WD19/22 programs running in background everyday by creating
a windows time schedule task of taskschd.msc with checking on
"Run whether user is looged on or not" and checked "Run with highest privileges"
and Configure for: Win7,Server 2008... with Trigger daily @ specific time.

And it works a charm.

HTH

King
Publicado el 14,septiembre 2017 - 06:41
Hi King

Thanks for that. The only issue I have with it is the time will change for different sets of records. So I am going to need this thing up permanently and trigger the procedure every x minutes just to check the time itself and then act on the time for each set of records. Will have to write something that stores the completion of a trigger and then proceed. Was just hoping that there was an easier way - getting lazy here :-)

Cheers
André
Publicado el 14,septiembre 2017 - 13:09
Hi André,

For continuous checks I use a service.
It's quite easy to create one in WD.

Kind regards,
Piet
Publicado el 18,septiembre 2017 - 14:15
Hi Piet

I do services as well in WD but how do you test for a procedure to trigger at a certain time every day without writing more code for this? Is there a setting somewhere?

André
Publicado el 18,septiembre 2017 - 14:57
If you are sure that your app is always running use one automatic procedure

https://doc.windev.com/en-US/…
Publicado el 19,septiembre 2017 - 08:35
Hi Andre
You say you want to run procedure so I guess you have your application started.
So, I use something like this to start procedure when all other are sleeping and company PC's
are not in use. Application is started only on server and wait time and for me it is started only one time. To avoid to be started more times in this 1 hour I use bAlreadyStarted .

bAlreadyStarted is boolean
sVrijemeJe is string = Left(TimeSys(),4) //Time string
IF sVrijemeJe >= "2300" AND sVrijemeJe <= "2359" THEN

IF bAlreadyStarted = True THEN RETURN

bAlreadyStarted = True

//Here put your code to execute whatever you want
//I start procedures to regenerate stocks, prices, optimization of database,...

ELSE
bAlreadyStarted = False
END

I am put additional protection and put registry key in my application so I can check this procedure for only one PC. So other PC's can not start this procedure even if same application is started.

Regards !
Publicado el 19,septiembre 2017 - 12:50
Hi André,

If I understand correctly what you are trying to do I would have a service running, doing a check every 5 minutes or so.
In the procedure you get the time from each dataset and check if it has already past.
Then you do your procedure and flag it done.

Kind regards,
Piet
Publicado el 20,septiembre 2017 - 09:56
Hi

Paulo - I can do that but it must only trigger at a specific time. I will be using that in combination with other code that determines if the procedure must be triggered.

ICI - excellent - that was pretty much where I was headed with a Timer checking every minute. I actually have dozens of procedures to be triggered so will write some code to discriminate on when they are triggered.

Piet - thanks that is what I will be doing. But will check more flags as the user actually decided when certain data will trigger the procedure and two sets may trigger at the same time.

Cheers
André
Publicado el 22,septiembre 2017 - 11:57
Hi ICI

Your code worked like a charm. Thanks a ton.

Cheers
André
Publicado el 22,septiembre 2017 - 15:34
I'm glad to help when I can and know how to help. :cheers: