|
|
|
|
|
- Declaration
- Using the ManualEvent variables
ManualEvent (Type of variable) In french: SignalManuel
The ManualEvent type is used to manage a manual event. A manual event is used to simplify the synchronization between several threads. 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 ManualEvent // 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 ... // Unlocks the main thread EventOpen(s)
Declaring a manual event (simple syntax) Hide the details
MyVariable is ManualEvent
In this case, the manual event is closed when it is created.
Declaring a manual event (advanced syntax) Hide the details
MyVariable is ManualEvent(<Initial status>)
<Initial status>: Integer constant Initial status of the event: | | eventOpen | The event is open when it is created. | eventClose | The event is closed when it is created. |
Remarks Using the ManualEvent variables The ManualEvent variables can be used to synchronize threads in the 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:
- all the pending threads are freed,
- all the threads that will reach the event later will go through without waiting.
During a call to EventClose (or <ManualEvent variable>.Close), the event is closed: all the threads that will reach the event later will remain locked.
This page is also available for…
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|