Official Content

Makes a pause for a given number of seconds during execution of a program.

Syntax

sleep(Seconds)
 
Where:

Seconds
    Is the number of seconds that the application will be waiting. It can be a numeric variable or a constant. .

Type Returned:
Numeric(1)

Scope

Objects:  Procedure, Transaction, Web Panel, Data Provider
Generators: .NET, .NET Framework, Java

Description

This function is useful, for instance, to implement a "daemon" to be executed with specific timeouts. The idea is to have an infinite loop and to have a waiting time of a specific number of seconds between each iteration. Thus, its use is recommended in 'batch' processes rather than in interactive applications, where the application 'dies' before the timeout specified is over.      

Sleep function is better than a loop because it does not consume CPU resources. It is implemented using the Thread.Sleep method of the .Net Framework / Java Virtual Machine.

Samples

&var = sleep(15)  // It waits 15 seconds and in &var it returns 0
&var = sleep(0)   // It waits  0 seconds and in &var it returns 0
&var = sleep(-10) // It waits  0 seconds and in &var it returns 0

See Also

Lapse property
Triggers property 






Last update: November 2024 | © GeneXus. All rights reserved. GeneXus Powered by Globant