Skip to main content
Version: Next

KILL WORKER

KILL WORKER {( process )}

ParameterTypeDescription
processText, IntegerNumber or name of process to kill (kills current process if omitted)

Description

The KILL WORKER command posts a message to the worker process whose name or number you passed in process, asking it to ignore any pending messages and to terminate its execution as soon as the current task ends.

This command can only be used with worker processes. For more information, please refer to the About workers section.

In process, you pass either the name or number of the worker process whose execution needs to be terminated. If no worker with the specified process name or number exists, KILL WORKER does nothing.
If you do not pass any parameter, KILL WORKER applies to the currently running worker and is therefore equivalent to KILL WORKER (Current process).

If KILL WORKER is applied to a worker that was not created explicitly using the CALL WORKER command (for example, the main application worker), it only asks this worker to empty its message box.

If the CALL WORKER command is called to send a message to a worker that was just killed by KILL WORKER, a new process is started. To make sure that there is only one process running at a time for a worker, the new process will start after the previous one is actually terminated. Note however that if CALL WORKER is called from a worker to send itself a message whereas it has just been killed by KILL WORKER, the command does nothing.

Example

The following code (executed from a form, for example) triggers the termination of a worker:

 CALL WORKER(vWorkerName;"theWorker";"end")

In the worker method (theWorker), you add some code to handle this situation:

  //theWorker method
 var $1 : Text //param
 
 Case of
    :($1="call") //the worker is called
       ... //do something
    :($1="end") //the worker is asked to kill itself
       KILL WORKER
 End case

See also

About workers
CALL WORKER
Current process name