0% found this document useful (0 votes)
67 views3 pages

Call Worker

Uploaded by

SamehTaresh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
67 views3 pages

Call Worker

Uploaded by

SamehTaresh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Search...

4D v16.6

Home
CALL WORKER
Home 4D v16.6 4D Language Reference CALL WORKER PROPERTIES 
4D Language Reference
Product: 4D

Process (Communications)
Process Theme: Process
(Communications)

(Communications)
CALL WORKER  Number: 1389

About semaphores
About workers  
CALL PROCESS CALL WORKER ( process ; method {; param}{; param2 ; ... ;  
paramN} ) 
CALL WORKER PAGE CONTENTS 
Parameter Type   Description
CLEAR process  Text, Longint Name or number of worker process Description

SEMAPHORE
method  Text Name of project method to call Example

GET PROCESS
VARIABLE param  Expression Parameter(s) passed to method
 
KILL WORKER HISTORY 
Semaphore Description
   Created: 4D v15 R5

SET PROCESS  
VARIABLE The CALL WORKER command creates or calls the worker
process whose name or ID you passed in process, and requests ARTICLE USAGE
Test semaphore the execution of the method in its context with the optional
4D Language Reference ( 4D
VARIABLE TO param parameter(s). v16)

VARIABLE The CALL WORKER command encapsulates the param 4D Language Reference ( 4D
v16.1)

parameters into a message and posts it in the worker's 4D Language Reference ( 4D


  message box. For more information on worker processes, v16.2)

  please refer to the About workers section. 4D Language Reference ( 4D


v16.3)

In the process parameter, you can specify the worker using its 4D Language Reference ( 4D
process name or its process number: v16.4)

4D Language Reference ( 4D
v16.5)

If you pass the number of a process that does not exist, 4D Language Reference ( 4D
or if the process specified was not created by CALL v16.6)

WORKER nor by 4D itself (such as the main application


process), CALL WORKER does nothing.  
If you pass the name of a process that does not exist, a  
new worker process is created.

Notes:

Worker process names are case sensitive.


The main process, created by 4D when a database is
opened for the user interface and the application mode,
is a worker process and can be called by CALL
WORKER. However, since its name can vary depending
on the 4D language, it is preferable to designate this
process using its number (always 1) when you use
CALL WORKER.

The worker process appears in the list of processes of the


Runtime Explorer and is returned by the PROCESS PROPERTIES
command when applied to this process.
In method, you pass the name of the project method to execute
in the context of the worker process. You can pass an empty
 
 
 
 
 
 
  string; in this case, the worker executes the method that was
© 1985-2019 4D SAS / 4D, Inc. All rights reserved.
originally used to start its process, if any (i.e., the startup
method of the worker).
Note: It is not possible to pass an empty string in method when
the command calls the main process (process number 1) since
it was not started using a project method. As a result, CALL
WORKER (1;"") does nothing.
You can also pass parameters to the method using one or more
optional param parameters. You pass parameters the same
way you would pass them to a subroutine (see the Passing
Parameters to Methods section). Upon starting execution in the
context of the process, the process method receives the
parameter values in $1, $2, and so on. Remember that arrays
cannot be passed as parameters to a method. Furthermore, in
the context of the CALL WORKER command, the following
additional considerations need to be taken into account:

Pointers to tables or fields are allowed.


Pointers to variables, particularly local and process
variables, are not recommended since these variables
may be undefined at the moment they are being
accessed by the process method.
If you pass an Object type parameter, 4D creates a copy
of the object in the destination process if the worker is
in a process different from the one calling the CALL
WORKER command.

A worker process remains alive until the application is closed or


the KILL WORKER command is explicitly called for it. To free up
memory, do not forget to call this command once a worker
process is no longer needed.

Example
 

In a form, a button starts a computation: for example, statistics


for the selected year. The button creates or calls a worker
process that computes the data while the user can continue to
work in the form.
The method of the button is:

  //call the worker vWorkerName with the


parameter

 C_LONGINT(vYear)

 vYear:=2015 // could have been selected by


the user in the form

 CALL
WORKER("myWorker";"workerMethod";vYear;Current
form window)

The code of workerMethod is:

  // this is the method of the worker

  // it can be preemptive or cooperative

 C_LONGINT($1) //gets the year

 C_LONGINT($2) //gets the window reference

 C_OBJECT(vStatResults) //to store statistical


results

 ... //compute statistics

  //once finished, calls the form back with


calculated values

  //vStatResults can display results in the


form

 CALL FORM($2;"displayStats";vStatResults)

 
 
 
 
 
 
  © 1985-2019 4D SAS / 4D, Inc. All rights reserved.
See also 
About workers

CALL FORM

Current process name

KILL WORKER

Previous page Next page  

 
 
 
 
 
 
  © 1985-2019 4D SAS / 4D, Inc. All rights reserved.

You might also like