Thanks Felipe,
Do you have an example of how to use this loop on a thread?
Sorry, but I don't know threads very well.
regards
Fabrício
Felipe Monteiro de Carvalho escreveu:
On 9/1/06, "Fabrício F. Kammer" <[EMAIL PROTECTED]> wrote:
I need to implement a routine on my sofware to be executed each 5
minutes.
Write a loop that first stores the current time, then executed
whatever you need, and then sleeps until current_time - previous_time
= 5 minutes. Like this:
while (not Terminated) do
begin
PreviousTime := Now;
// Do what you need to do
{----------------------------------------------
"sleeps" while currentTime - PreviousTime isn´t bigger then 5
minutes
----------------------------------------------}
while (Now - PreviousTime < 5 minutes) do
begin
Sleep(1000); // May be bigger
end;
end;
You can use the Now function here because 5 minutes a lot of time, and
so you don´t really need a lot of precision.
If you needed a nanosecond precision on your loop you could use the
powerful EpikTimer component:
http://wiki.lazarus.freepascal.org/EpikTimer
If you want to receive user input while your loop runs, then put the
loop on a separate thread.
_______________________________________________
fpc-pascal maillist - fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal