version 6.0
Multi-tasking in 4th Dimension is the ability to have distinct database operations that are executed simultaneously. These operations are called processes.
Multiple processes are like multiple users on the same computer, each working on his or her own task. This essentially means that each method can be executed as a distinct database task.
This section covers the following topics:
Creating and clearing processes
Elements of a process
User processes
Processes created by 4th Dimension
Local and global processes
Record locking between processes
Note: This section does not cover stored procedures. See the section Stored Procedures in the 4D Server Reference manual.
Creating and Clearing Processes
There are three ways to create a new process:
Execute a method in the User environment after checking the New Process check box in the Execute Method dialog box. The method chosen in the Execute Method dialog box is the process method.
Processes can be run by choosing menu commands. In the Design environment's Menu Bar editor, select the menu command and click the Start a New Process check box. The method associated with the menu command is the process method.
Use the New process function. The method passed as a parameter to the New process function is the process method.
A process can be cleared under the following conditions. The first two conditions are automatic:
When the process method finishes executing
When the user quits from the database
If you stop the process procedurally or use the Abort button in the Debugger
If you choose Abort from the Process menu in the Design environment
A process can create another process. Processes are not organized hierarchicallyall processes are equal, regardless of the process from which they have been created. Once the "parent" process creates a "child" process, the child process will continue regardless of whether or not the parent process is still executing.
Elements of a Process
Each process contains specific elements. There are three types of distinctly different elements in a process:
Interface elements: Elements that are necessary to display a process.
Data elements: Information that is related to the data in the database.
Language elements: Elements that are used procedurally or are that are important for developing your own application.
Interface Elements
Interface elements consist of the following:
Menu bar: Each process can have its own current menu bar. The menu bar of the frontmost process is the current menu bar for the database.
One or more windows: Each process can have more than one window open simultaneously. On the other hand, some processes have no windows at all.
One active (frontmost) window: Even though a process can have several windows open simultaneously, each process has only one active window. To have more than one active window, you must start more than one process.
Data Elements
Data elements refer to the data used by the database. The data elements are:
Current selection per table: Each process has a separate current selection. One table can have a different current selection in different processes.
Current record per table: Each table can have a different current record in each process.
Note: This description of the data elements is valid if your processes are global in scope. By default, all processes are global. See the "Global and Local Processes" section below.
Language Elements
The language elements of a process are the elements related to programming in 4th Dimension.
Variables: Every process has its own process variables. See Variables for more information. Process variables are recognized only within the domain of their native process.
Default table: Each process has its own default table. However, note that the DEFAULT TABLE command is only a typing convention for programming.
Input and Output forms: Default input and output forms can be set procedurally for each table in each process.
Process sets: Each process has its own process sets. UserSet and LockedSet are process sets. Process sets are cleared as soon as the process method ends.
On Error Call per process: Each process has its own error-handling method.
Debugger window: Each process can have its own Debugger window.
User Processes
User processes are processes that you create to perform certain tasks. They share processing time with the kernel processes. As an example, Web connection processes are user processes.
Processes Created by 4th Dimension
The following processes are created and managed by 4th Dimension:
User/Custom Menus process: The User/Custom Menus process consists of the Custom Menus and the User environments. The default splash screen window in the Custom Menus environment is also a part of the User/Custom Menus process. This process is created as soon as 4th Dimension is run.
Design process: The Design process consists of the Design environment running as a separate process. It can be closed using the Exit Design Environment menu command in the File menu of the Design environment. There is no Design process in a compiled database. The Design process is created only when the user enters the Design environment for the first time. If the application opens in the User or Custom Menus environment, by default, the process will not be created.
Web Server process: The Web Server process runs when the database is published on the Web. See the section Web server configuration and connection management for more information.
Cache Manager process: The Cache Manager process manages disk I/ O for the database. This process is created as soon as 4th Dimension or 4D Server are run.
Indexing process: The Indexing process manages the indexing of fields in a database as a separate process. This process is created when an index for a field is built or deleted.
On Event Manager process: This process is created when an event-handling method is installed by the ON EVENT CALL command. It executes the event method installed by ON EVENT CALL whenever there is an event. The event method is the process method for this process. This process executes continuously, even if no method is executing. Event handling also occurs in the Design environment.
Global and Local Processes
Processes can be either global or local in scope. By default, all processes are global.
Global processes can perform any operation, including accessing and manipulating data. In most cases, you will want to use global processes.
Local processes should be used only for operations that do not access data. For example, you can use a local process to run an event-handling method or to control interface elements such as floating windows.
You specify that a process is local in scope through its name. The name of local process must start with a dollar sign ($).
Warning: If you attempt to access data from a local process, you access it though the User/Custom Menus process, risking conflicts with operations performed within that process.
4D Server: Using local processes on the Client side for operations that do not require data access reserves more processing time for server-intensive tasks.
Record Locking Between Processes
A record is locked when another process has successfully loaded the record for modification. A locked record can be loaded by another process, but cannot be modified. The record is unlocked only in the process in which the record is being modified. A table must be in read/write mode for a record to be loaded unlocked.
See Also
Methods, Project Methods, Variables.