Exchanging messages between processes

4D v15 R5 introduces a new, simple and powerful way to exchange information between processes and also between processes and forms. This feature is based upon an asynchronous messaging system that allows processes and forms to be called and asked to execute methods with parameters in their own context.

The Worker Process

A worker has a message box. The worker process is created at first use and its associated process is also automatically launched at first use. Unlike the “New process” command, a worker process remains alive after the end of the method execution.

A worker can call itself in order to work on large jobs in chunks. The workers will drastically reduce the need for inter-process variables as well as the need for semaphores to allow parallel asynchronous processing. A worker is required for preemptive multi-threading. However, a worker can be used with cooperative processes, so it is also useful with 32-bit or interpreted environments.

Two new commands are available:

  • CALL WORKER” encapsulates the project method name and any parameters into a message and posts it in the worker’s message box.

CALL WORKER (process name|process number;project method name;param1;…;paramN)

  • KILL WORKER” posts a message to the specified worker asking it to forget any pending message and to kill itself.

KILL WORKER (nothing|process name|process number)

An example database is available to demonstrate the new functionality:

Example Database

Call Form

Now, each form running in a window has a message box.CALL FORM” allows a project method to be executed with arguments in the context of a form displayed in a window, regardless of the process owning the window.

The command makes using “CALL PROCESS” together with inter-process variables to pass messages obsolete. “CALL FORM” can be used inside a form context to call itself in order to stack or chunk work. This eliminates the need for workarounds such as SET TIMER(1). While extremely necessary for preemptive processes, it also works with cooperative processes, with 32-bit or interpreted environments.

The syntax is:
CALL FORM (window reference;project method name;param1;…;paramN)

Similarly to “CALL WORKER”, “CALL FORM” encapsulates the method name and command arguments in a message that is posted in the form’s message box. The form then executes the message in its own process.

An example database is available to demonstrate the new functionality:

Example Database

For more details, please take a look at the 4D v15 R5 Upgrade manual.

Vanessa Talbot
• Product Owner •Vanessa Talbot joined 4D Program team in June, 2014. As a Product Owner, she is in charge of writing the user stories then translating it to functional specifications. Her role is also to make sure that the feature implementation delivered is meeting the customer need.Since her arrival, she has worked to define key features in 4D. She has worked on most of preemptive multi-threading new features and also on a very complex subject: the new architecture for engined application. Vanessa has a degree from Telecom Saint-Etienne. She began her career at the Criminal Research Institute as a developer for the audiovisual department. She has also worked in media and medical fields as expert in technical support, production as well as documenting new features.