[Lazarus] sleep function don't passed before executing the next statement

Michael Schnell mschnell at lumino.de
Mon Nov 19 10:43:29 CET 2012


On 11/19/2012 10:08 AM, Eric Kom wrote:
>
> after included the Crt library in my lazarus file, when I called the 
> functions sleep() or delay(), the function do not execute the previous 
> statement, pass  and execute the next as below:
>
> StatusBar.SimpleText := 'My name is Tux';
> sleep(100);
> StatusBar.SimpleText := 'am ready';
>

Using sleep in this way does not make sense at all.

  - Any GUI action (i.e. displaying changes) is blocked while the main 
is sleeping.
  - the GUI actions are performed by events and can will be performed at 
"some reasonable point in time" after the action is scheduled by the 
user program.

The purpose of sleep() is nothing but "allowing for other threads and 
processes to use the CPU for at least the given milliseconds".

-Michael




More information about the Lazarus mailing list