Adding a Background Procedure

Navigation:  How to Work with Background Procedures >

Adding a Background Procedure

Previous pageReturn to chapter overviewNext page

 

Overview

 

Creating a background procedure in a project requires two major operations - defining the background procedure's structure (name, Input/Output Background variables) and the adding of processes to that structure in its "Procedure" tab. The added processes will depend on the background procedure's purpose/business logic to implement.

 

As an alternative, you can import a background procedure that was created in another project and exported into the "Library Manager".

If that imported background procedure was previously locked during its export from another project, you will NOT be able to edit it after importing it into the destination project.

See Exporting/Importing a Background Procedure.

 

 

By definition, a background procedure is not supposed to receive any user input. Therefore, screens, controls or processes that call or imply user interface elements (ex: the Display Controls processes group) are NOT available for background procedures. The processes that CANNOT be used within a background procedure are grayed out.

 

When creating the business logic for the background procedure (the adding of processes into its "Procedure" tab), ALWAYS bear in mind the target device for the current application. Consider the target device's memory/processing capabilities because it must be able to handle the execution of the foreground application (main thread) and the running background procedure(s) in secondary thread(s).

 

 

To Add a Background Procedure

 

Step-by-step

 

1. Open the “Procedures” module and right-click the module's empty area or the "Background Procedures" section name.

Example of a right-click menu in an empty area of the "Procedures" module:

 

 

2. Select the “Add Background Procedure” option.This opens a properties window for the new background procedure.

 

 

3. In the "General" tab, enter a name for the background procedure or keep the suggestion. This name will be displayed in the tree view.

Optionally, you can also add notes about the new background procedure.

 

The name of the background procedure MUST be unique throughout the project (ex: You cannot have a program and a background procedure with the same name).

 

 

4. Go to the "Input" tab.

 

 

5. Define the Input Background variables for the background procedure:

 

"Input Variable"

Click to create/select the Input Background variable, within the background procedure, that will receive data from the foreground (running program). See User Defined Variables.

 

"Init Value"

Optionally, define a default value to be assigned to the corresponding Input Background variable, in case the calling process does not map it. Enter it OR  click and select a variable with the intended value.

 

"Description"

If required, use this column to add information about the corresponding input variable/value.

 

Use the editing icons to the right of the table to move the rows up and down and to delete or add more rows.

 

6. Go to the "Output" tab.

 

 

7. Define the Output Background variables for the background procedure:

 

"Output Variable"

Click to select/create an output variable for the background procedure that will return data to the foreground.

 

"Description"

If required, use this column to add information about the corresponding output variable/value.

 

Use the editing icons to the right of the table to move the rows up and down and to delete or add more rows.

 

8. Continue to the "Procedure" tab.

 

 

9. Add the required processes to execute the background procedure's business logic. You can drag-and-drop the processes from the "Process" tab, use the process list window or right-click a row and select "Add/Insert..." in the resulting menu. See Adding Processes to Routines, "Routine In", "Routine Out", Local or Global Procedures, Background Procedures or Global Events.

 

10. Click to apply OR to abort the operation.

 

As an alternative, you can import an existing background procedure from Library. See To Import a Background Procedure from Library.

 

 

All the background procedures of a project are available in the "Procedures" module.

They are called by the program running in the foreground with a "Call Background Proc" process. See Working with "Call Background Proc" Process.

 

As an alternative, you can use the following shortcut to include a background procedure to a screen, a control, a "routine in", a "routine out" or a global event:

If you drag a previously created background procedure from the "Procedures" module onto a screen/control (specifically, to the "Actions" tab), a "routine in"/"routine out" (onto its "Routine" tab) or a global event (onto its "Event" tab), it automatically adds a "Call Background Proc" process.