Usina BRAdvPL Guide
Sign in
← All topics
FUNCTIONUnder review

Sleep

Sleep(nMilliseconds)

Pauses the executing thread for milliseconds.

SleepAdvPL
01 · OVERVIEW

Overview

The pause affects the calling thread. It neither confirms external-task completion nor guarantees exact real-time timing; scheduling also matters. Bound waits and avoid sleeping while holding locks or transactions. This example waits 25 milliseconds without data access. (Sources: refs. 1–2.)

02 · SYNTAX

Syntax

Sleep(nMilliseconds)

Parameters

nMilliseconds
NumericRequired

Interval in milliseconds.

Return value

Return unspecified on the page; unused.

03 · PRACTICAL EXAMPLE

Commented example

#Include "Protheus.ch"

User Function Ed666()
    // Short bounded pause outside transactions or locks.
    Sleep(25)
    ConOut("Pause completed")
Return Nil
Expected result

Requests a 25 ms pause and continues; exact duration was not measured. Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.

BEST PRACTICES
  • Avoid infinite polling; design task timeout and cancellation.
  • Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.

Related content

REFERENCES
  1. TOTVS. Sleep. Sintaxe e observações. TDN. Accessed on 2026-10-28.
  2. Atilio. dan-atilio/AdvPL. Maratona de Exemplos/Exemplo_447_Funcao_Sleep.prw. Arquivo completo consultado; adaptação editorial. Accessed on 2026-10-28.
Status
Under review
Page created on
Last reviewed on
Original language
Portuguese
Reviewed by
Usina.BR
0 approved comment(s)

Comments

There are no approved comments yet.

Sign in with Google or Microsoft to comment.

Powered by Usina Docs · Alpha