SRL Archive - Delphi/FPC Help and Tutorials

[LAZARUS] Alternate to Sleep()?


Footy

2012-11-26 15:35:52

When making apps in lazarus, whenever I use sleep, it does weird things. For example, I can't close the screen while its sleeping, I can't resize it, no Onclick events can be called, everything freezes for however long it's sleeping. Is there an alternative to sleep that will still keep everything functional?

Thanks :D
Footy

E: Found this suggestion online. The only downside is when I am moving a screen, everything stops, but atleast it's better then it was.

Procedure FSleep(Time : Integer);
var
i:integer;
begin
for i := 0 to Time do
begin
sleep(1);
Application.ProcessMessages;
end;
end;

Killerdou

2012-11-26 17:35:33

to prevent the counting to stop you could have it loop untill time passed is big enough, rather than sleep(1) as many ms as you would like to sleep