Skip to content

WaitForCondition()

Synopsis

Wait (sleep) until the given condition is true.

Description

Waits until expression evaluates to true, checking every interval seconds for up to timeout. Default is evaluate expression every 50 milliseconds with no timeout.

Example: Wait for condition dialplan variable/function to become 1 for up to 40 seconds, checking every 500ms
same => n,WaitForCondition(#,#["#{condition}"="1"],40,0.5)
Sets WAITFORCONDITIONSTATUS to one of the following values:

  • WAITFORCONDITIONSTATUS

    • TRUE - Condition evaluated to true before timeout expired.

    • FAILURE - Invalid argument.

    • TIMEOUT - Timeout elapsed without condition evaluating to true.

    • HANGUP - Channel hung up before condition became true.

Syntax

WaitForCondition(replacementchar,expression,[timeout,[interval]])
Arguments
  • replacementchar - Specifies the character in the expression used to replace the '$' character. This character should not be used anywhere in the expression itself.

  • expression - A modified logical expression with the '$' characters replaced by replacementchar. This is necessary to pass the expression itself into the application, rather than its initial evaluation.

  • timeout - The maximum amount of time, in seconds, this application should wait for a condition to become true before dialplan execution continues automatically to the next priority. By default, there is no timeout.

  • interval - The frequency, in seconds, of polling the condition, which can be adjusted depending on how time-sensitive execution needs to be. By default, this is 0.05.

Generated Version

This documentation was generated from Asterisk branch 21 using version GIT