Hola anubis.
En este enlace:
Velocidad de un timer, tenes un ejemplo de como implementar un timer con thread. Escribí el código para
Delphi pero lo acabo de probar en
Lazarus y funciona perfectamente con solo hacer unos pequeños cambios.
En la unidad uTimeThread:
Código Delphi
[-]
procedure TTimeThread.Execute;
begin
while not Terminated do
Synchronize(@WaitInterval); end;
Y en el ejemplo de uso:
Código Delphi
[-]
procedure TForm1.btnComenzarClick(Sender: TObject);
begin
if not Assigned(TimeThread) then
begin
FCont := 1;
TimeThread:= TTimeThread.Create;
TimeThread.Interval := 100000;
TimeThread.OnTime := @TimeThreadOnTime; TimeThread.Execute;
end;
end;
La adaptación a un
TProgressBar es tan simple como:
Código Delphi
[-]
procedure TForm1.TimeThreadOnTime;
begin
if (ProgressBar1.Position = 100) and Assigned(TimeThread) then
TimeThread.Terminate;
ProgressBar1.Position:= FCont;
Inc(FCont);
Application.ProcessMessages;
end;
Saludos
