|
|
|
|
|
- Declaration
- Using the AutomaticEvent variables
AutomaticEvent (Type of variable) In french: SignalAutomatique
The AutomaticEvent type is used to manage an automatic event. An automatic event is used to simplify the synchronization between several threads. After its opening, an "Automatic" event is automatically closed as soon as a single thread is unlocked. Remark: We recommend that you use an AutomaticEvent or ManualEvent variable to create an event rather than naming it using a character string. Indeed, using a variable allows you to: - manage the variable scope,
- avoid having 2 events with the same name in 2 different threads.
// MAIN THREAD //------------------ // Define the event s is AutomaticEvent // Start the thread ThreadExecute("Thread", threadNormal, ProcThread, s) Â // Code in parallel with the thread ... // Wait for the event triggered by the thread EventWait("s") // SECONDARY THREAD // ---------------------- PROCEDURE ProcThread(s) Â // Code in the thread ... // Unlock the main thread EventOpen(s)
Declaring an automatic event (simple syntax) Hide the details
MyVariable is AutomaticEvent
In this case, the automatic event is closed when it is created.
Declaring an automatic event (advanced syntax) Hide the details
MyVariable is AutomaticEvent(<Initial state>)
<Initial state>: Integer constant Initial state of the event:
| | eventOpen | The event is open when it is created. | eventClose | The event is closed when it is created. |
Remarks Using the AutomaticEvent variables The AutomaticEvent variables can be used to synchronize threads in functions: - standard syntax:
| | EventClose | Closes a synchronization event between several threads. | EventOpen | Opens a synchronization event between several threads. | EventWait | Locks the current thread while waiting for the specified event to be opened. |
- prefix syntax:
This page is also available for…
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|