ParallelTaskExecute (Function) In french: TâcheParallèleExécute Triggers the execution of a parallel task.
// Utilisation de la syntaxe 1 t1 is ParallelTask = ParallelTaskExecute(ProcédureA, (), ptoMainThread)
// Utilisation de la syntaxe 2 t1 is ParallelTask t1.Procédure = Procédure3 t2 is ParallelTask = ParallelTaskExecute(t1)
// Utilisation de la syntaxe 3 t3 is Description of ParallelTask t3.Procédure = Procédure3 ParallelTaskExecute(t3)
// Utilisation de la syntaxe 3 t3bis is Description of ParallelTask t3bis.Procédure = Procédure3bis t3bis.Parameter[1] = Today() t3bis.Parameter[2] = TimeSys() ParallelTaskExecute(t3bis)
// Déclaration de plusieurs tâches et exécution d'un traitement à la fin de toutes ces tâches MaDescriptionTâche is Description of ParallelTask tabMesTâches is array of ParallelTask // Résultat des fonctions tâches parallèles // Tâche N°1 MaDescriptionTâche.Procédure = Exemple2_Etape1 // Exécute les tâches parallèles // On ajoute la tâche renvoyée à un tableau de tâches // pour pouvoir les réutiliser dans la fonction TâcheParallèleExécuteAprèsToutes Add(tabMesTâches, ParallelTaskExecute(MaDescriptionTâche)) // Tâche N°2 MaDescriptionTâche.Procédure = Exemple2_Etape2 Add(tabMesTâches, ParallelTaskExecute(MaDescriptionTâche)) // On donne la procédure à exécuter une fois que // toutes les tâches contenues dans le tableau tabMesTâches sont terminées ParallelTaskExecuteAfterAll(tabMesTâches, Exemple2_Fin, (), ptoMainThread)
Syntax
Running a parallel task Hide the details
<Result> = ParallelTaskExecute(<Procedure> [, <Parameters> [, <Options>]])
<Result>: ParallelTask variable ParallelTask variable corresponding to the task to run. <Procedure>: Character string or Procedure variable Procedure to run. This parameter can correspond to: - the name of the procedure to run.
- the name of Procedure variable corresponding to the procedure to run.
<Parameters>: List of values enclosed in brackets and separated by commas Parameters of procedure to run. This list of parameters has the following format:
(<Paramètre 1>, ..., <Paramètre N>)
where: - <Parameter 1>: First procedure parameter.
- ...
- <Parameter N>: Nth procedure parameter.
Caution: Parameters are passed by value. In the case of variables of complex types (arrays, object), the value is the element itself.. To protect access to this variable, one of the following solutions can be used: - make a copy of the variable (with the LOCAL keyword),
- use critical sections (with 3077001 or the <critical section> attribute)
<Options>: Optional Integer constant (or combination of constants) Options of task to run: | | ptoDelayedCopyHFSQLContext (Default value) | Triggers a light copy of HFSQL context during the first access to the HFSQL data. | ptoFullCopyHFSQLContext | Triggers the immediate copy of the current HFSQL context. Recommended, for example, if the parallel task must take into account the current positions in the files and queries of the context of the caller. | ptoLightCopyHFSQLContext | Triggers the immediate copy of a part of the current HFSQL context. Only the directories containing the data files in HFSQL Classic mode and/or the connections in HFSQL Client/Server mode are stored. | ptoMainThread | Runs the task in the main thread. This constant can be combined with one of the other constants.
Caution: This constant cannot be used to run a parallel task in the main thread from the main thread. |
Remark: To find out which type of copy to choose, see the comparison between the different copy modes.
Running a parallel task described beforehand (ParallelTask variable) Hide the details
<Result> = ParallelTaskExecute(<Task>)
<Result>: ParallelTask variable ParallelTask variable corresponding to the task run. <Task>: ParallelTask variable Name of the ParallelTask variable corresponding to the task to run. Caution: A WLanguage error occurs if the task is currently run or if the task was already run.
Running a parallel task identified by its description (Description of ParallelTask variable) Hide the details
<Result> = ParallelTaskExecute(<Task description>)
<Result>: ParallelTask variable ParallelTask variable corresponding to the task run. <Task description>: Description of ParallelTask variable Name of the Description of ParallelTask variable that describes the task to be executed. Remarks - The task is saved in the queue of tasks to run.
- ParallelTaskExecute is not a blocking function and does not wait for task to be completed.
- Comparison between the different types of copy for the HFSQL context:
| | | Type of copy | Benefits | Drawbacks |
---|
Full copy | copy: - the extensive connection parameters (connections, physical paths, ...).
- the positions, the filters, ... defined on the data files.
- the queries.
| Memory consumption (on the client and on the server). | Light copy | Copies the extensive connection parameters (connections, physical paths, ...). No memory consumption on the server. | The records and the current filters are not copied. Therefore, the records must be repositioned by HReadSeek for example. No copy of queries. Memory consumption on the Client computer | Delayed copy | No memory consumption (on the client and on the server). | Risk: If the extended connection parameters are modified, the last modification will be taken into account. The records and the current filters are not copied. Therefore, the records must be repositioned by HReadSeek for example. No copy of queries. |
In most cases, the delayed copy is recommended provided that you don't change the connection parameters and that you perform the necessary calls to HReadSeek.
Related Examples:
|
Unit examples (WINDEV): Using parallel tasks
[ + ] The parallel tasks are used to speed up the process times and to improve the reactivity of an application. This example presents the functions and types of variables required to use the parallel tasks: - running parallel tasks, - interaction with the controls, - continuation tasks.
|
This page is also available for…
|
|
|
|