4D v14

Processes

Home

 
4D v14
Processes

Processes    


 

 

In addition to the manipulations explained in the video, you should note that: 

A process is an environment that possesses:

  • its own memory space
  • its current selections (one per table)
  • its own variables (process variables)
  • possibly its own interface
  • and so on.

Processes can communicate between themselves in different ways:

  • interprocess variables
  • reading or writing variables
  • etc.

They can:

  • be put to sleep (sleep process)
  • be put in hibernation (suspended process) until another process wakes them up.

A process only dies when the method it executes is completed.
You cannot force a process to die programmatically, even though you can program it to die in certain conditions (see the CALL PROCESS command) 

Processes generally serve the following purposes:

  • create particular processes (batches, “submarine” checks),
  • create tool palettes (independent windows with specific functions),
  • display input/display dialogs so that the user can work with multiple windows.

4D directly generates certain processes.

A process is creating using the New process command:

 vProcessNumber:=New process(Method;Stack;Processname;Settings;...)

This command line must be in the method. We recommend using the concept shown below; you’ll save time and clarity:

 C_TEXT($1)
 If(Count parameters=0) // If no parameter is received, you must create the process
    C_LONGINT(<>ProcessNumber)
    <>ProcessNumber:=New process("Display_Stats2";1024*1024;"Statistics";"Fictitious_Parameter") // create the process
 Else // If the method receives at least one parameter, you need to execute the display method
    C_LONGINT($Window//Create the window (container) in which the dialog is displayed (content)
    $Window:=Open form window("STATS";Plain form window;Horizontally centered;Vertically centered)
    DIALOG("STATS") //Display the dialog
    CLOSE WINDOW($Window// Once the dialog is closed, shut the window
 End if

  • When calling the method (without parameters), 4D creates a process in which it executes a method.
  • The method calls itself (it create a second instance of the method in the new process)
  • and passes itself a parameter:
  • The first method ends
  • while the method executed by the process continues along and presents the statistics array.

As such, you can continue to work while having the statistics window at your fingertips.

To trace the execution of a process (when you execute the New Process line), use the “step-by-step new process” button. This button executes the line and opens a second trace window in which you can follow the progress of the executed method in the process, independently of the calling method.

For example, you can create a process that displays the time and elapsed time since the new process started. This example will give you the basics of setting up a time counter.

Processes allow you to consider quick evolutions in your programming:

  • You can conceptualize your processes,
  • test them in several lines of code,
  • then set them for independent execution in a process.

There are numerous examples of using processes. Here’s one more: you have updates to perform on an important database; however, these updates can be staggered by several seconds or even minutes without having an impact on your company’s performance. So you can:

  • plan on having a table where you save a to-do list of tasks to perform.
  • For each of these tasks, you specify a date, a time, and possibly a priority level and a description of the task to perform (what? on what table? what record? etc.).
  • Then, set in motion a process whose sole mission is to consult this process table and perform the set of tasks for it.
  • When it finishes this, it is suspended until a new task is recorded and the process is re-enabled.

This operation is quite feasible in client / server mode where a process (stored procedure) "runs" on the server and carries out the tasks to be performed:

  • imports
  • reprocessing
  • PDF printing
  • sending of e-mails
  • and so on.

 
 

 
PROPERTIES 

Product: 4D
Theme: Processes

 
ARTICLE USAGE

Self-training ( 4D v13)
Self-training ( 4D v14)