When using scripts in a Reliance project, you may have encountered the situation when processing a script took a long time. It might have been a script that performed a calculation with data stored in a database, a script that exported data from a database to another format, etc. If there was a request for running another script during the lengthy operation, the script was run only after the completion of processing the current script. If such a delay is undesirable, it is possible to take advantage of the parallel processing of scripts (this feature was introduced in Reliance 4.0.15).
The code of a script is executed by the so-called thread (thread of execution). In a Reliance 4 project, 31 predefined threads are available for script processing.
Project Options – Script threads
For every script, you can select a thread to process the script. By default, all scripts in a project are processed by "Thread1". In this case, scripts are processed one after another, i.e., at most one script at a time. By dividing scripts into different threads, it is possible to achieve the parallel processing of multiple scripts. Scripts processed in different threads don't block each other.
Most frequently, there are 2 script groups: scripts for fast operations (e.g., calculations of internal tags for display purposes) and lengthy operations (e.g., with databases, as mentioned above). As a result, lengthy operations don't block fast operations.
Script Manager – Selecting a thread for a script
Script Manager – Selecting a thread for a script
Please note:
Scripts running in different threads should not work with the same data (e.g., the same group of tags in a project). Otherwise, access to data needs to be synchronized so that multiple scripts don't read and write the same data at the same time.
Scripts running in different threads don't share global identifiers, such as constants, variables, procedures, and functions. Each thread has its own copy of global identifiers.
Haven't found what you were looking for? Use this form to inform us about it.