STOP-AFTER phrase
- Last Updated: October 18, 2024
- 2 minute read
- OpenEdge
- Version 12.2
- Documentation
STOP-AFTER phrase specifies a time-out value for
a DO, FOR, or REPEAT block.Syntax
|
- time-limit
- An integer expression which specifies the number of seconds each iteration of a block has until a time-out occurs.
If a time-out occurs, the AVM raises the STOP condition on the current statement and throws a Progress.Lang.StopAfter object. Use an ON STOP
phrase on the block (or an enclosing block) to alter the default STOP condition handling. Alternatively you can catch a Progress.Lang.StopAfter object using a CATCH
block to provide alternate STOP condition handling. For
more information, see the Progress.Lang.StopAfter class.
The STOP-AFTER time limit is the maximum
time allowed for a single block iteration. For example, if you have STOP-AFTER 3 on a FOR EACH statement, each
loop iteration must complete within 3 seconds or a STOP
condition is raised.
If a block with a STOP-AFTER phrase
contains a nested block with a STOP-AFTER phrase, then
each is governed by it's own time limit. If the outer block time limit is reached while the
inner block is executing, the STOP condition is raised
even if the time limit for the inner block has not been reached.
If the STOP condition is handled and
execution resumes within the scope of a block with a STOP-AFTER phrase, the time limit is not in effect until the next iteration of
the block
If time-limit evaluates to zero or
less, this is the equivalent of not specifying a STOP-AFTER phrase.
Examples
Example 1
The following example shows how the STOP-AFTER phrase can be used for placing a time limit on a query.
|
Example 2
The following example demonstrates how a STOP-AFTER
phrase on an outer block also limits the time allowed for an inner block.
|
If you run this code, the outer DO block
establishes a 5 second time limit for the work of the DO
block and all inner blocks.
When the inner FOR EACH block starts, a
separate time limit is set for each iteration of this block due to the STOP-AFTER 10 phrase.
Execution then continues to the REPEAT
block which is an infinite loop. At some point, the outer 5 second time limit of the
DO block is reached and the AVM raises the STOP condition. The STOP
condition is raised on the statement the AVM is executing when the time limit is reached.
Normal STOP handling proceeds from that point.
Because a CATCH statement on a block takes precedence over an ON
STOP phrase, the STOP condition is caught and the "Time
limit reached..." message displays. Notice that 5 seconds elapse from the "Start
of DO BLOCK..." message to the "Time limit reached..." message.
Normal execution resumes following the DO block, and the
"Procedure complete." message displays.
Notes
STOP-AFTERphrases are not intended to interact with user interfaces.- Blocking calls to third party software components, where the AVM has transferred execution control, cannot be timed out. This category includes operating system calls, MS Windows system calls, and calls to any third party DLLs and Unix shared objects.
See also
CATCH statement, DO statement, FOR statement, ON STOP phrase, Progress.Lang.StopAfter class, REPEAT statement