Abort Task

C Definition

void dms_AbortUserTask(long TaskNumber)

Pascal Definition

procedure dms_AbortUserTask(TaskNumber:longint);

Description

This command causes a procedure in the controller to abort execution. Resident application procedures to be managed should be named UserTask1, UserTask2, etc. The task number is referenced by this command.

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.

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.

Note that the EscapeResult parameter must be preset to 0 before making the call or the routine will not run

Related Topics

Yield
Abort Task
Task Present