Abort Task

Tasks Block

Description

This command causes a procedure in the controller to abort execution. Only procedure blocks can be included within the Abort Task block. Multiple procedures can be enclosed within Abort Task and all enclosed procedures will aborted.

A task can only be aborted with Abort Task if it had been started with Begin Task. A Task Identity is the procedure name that was used with the Begin Task command that started it. A procedure that is called directly by another block list cannot be aborted because the procedure is running under the name of the enclosing procedure. All of the tasks inside the Abort Task block are aborted on the same controller sample. The order of the blocks does not matter since all of the aborting occurs at the same discrete time moment.

After aborting a task it is often necessary to "clean up" the residual condition of resources the task had been managing. For example if a homing procedure was using the Jog command to home and was counting on the detection of a sensor to stop it, aborting the homing routine would leave the motor still jogging but with no reason to stop. If a task managing a blinking light is aborted the light might remain in an active condition. It is usually better to avoid using the Abort Task command and to instead have the task terminate itself, and clean up after itself, based on a boolean variable.

Escapes

The Abort Task block does not generate any escapes.

Examples

This alternative method illustrates how to have a procedure stop without using Abort Task allowing it to clean up resources on its own:

Related Topics

Yield
Abort Task
Task Present