Cicode Programming Reference > Cicode Function Categories > Task Functions Introduction > TaskKill

TaskKill

Kills a task. The Cicode task will be stopped and will not run again.

Syntax

TaskKill(hTask)

hTask:

The task handle, returned from the TaskNew() or TaskHnd() function. The task handle identifies the table where all data on the associated task is stored.

Return Value

0 (zero) if successful, otherwise an error is returned.

Note: TaskKill is an abrupt way to stop a Cicode task. It can cause system errors and may have unintended consequences. Whenever possible, use TaskGetSignal and TaskSetSignal to stop Cicode tasks. Use TaskKill as a last resort and after observing the following:

 

UNINTENDED EQUIPMENT OPERATION

  • Do not use TaskKill to stop Cicode tasks until you have attempted the alternative methods stated above.
  • Place the processes and devices controlled by CitectSCADA into a state preventing unintended operation before using TaskKill to stop a Cicode task.

Failure to follow these instructions can result in death, serious injury, or equipment damage.

Related Functions

TaskGetSignal, TaskSetSignal, TaskHnd, TaskNew, TaskResume, TaskSuspend

Example

! Create a task, run it for 10 seconds and then kill it.
hTask=TaskNew("MyFunc","",0);
Sleep(10);
TaskKill(hTask);
FUNCTION
MyFunc()
INT Count;
WHILE 1 DO
Prompt("Hello "+Count:###);
Count=Count+1;
END
END

See Also

Task Functions