[Lazarus] timer in a console application

Michael Schnell mschnell at lumino.de
Fri Aug 10 14:43:52 CEST 2012


On 08/10/2012 02:38 PM, michael.vancanneyt at wisa.be wrote:
>   while not fStopExecution do
>     begin
>     CheckSynchronize;
>     inc(i);
>     end;
This results in 100 % CPU (in a single CPU system) so not a very good 
idea IMHO. (Even the timer thread is crippled by the main thread.)

If you can live with some latency I would do something like:

    while not fStopExecution do
      begin
      CheckSynchronize;
      sleep(Max_Latancy);
      end;

-Michael




More information about the Lazarus mailing list