|
|
|
|
|
- Declaration
- Using the ManualEvent variables
ManualEvent (Variable type)
The ManualEvent type is used to manage a manual event. A manual event is used to simplify the synchronization between several threads. Note: It is preferable to use a variable of type AutomaticEvent or ManualEvent variable to create a signal, rather than naming it using a 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 // ---------------------- PROCÉDURE ProcThread(s)
// Code in the thread ... // Unlocks the main thread EventOpen(s)
In this case, the manual event is closed when it is created.
Declaring a manual event (advanced syntax) Ocultar los detalles
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. |
Observaciones 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 | Bloquea el hilo actual mientras espera a que se abra el evento especificado. |
- prefix syntax:
- all the pending threads are freed,
- all the threads that will reach the event later will go through without waiting.
When calling the EventClose (or <ManualEvent variable>.Close) function, the signal is closed: all threads reaching the signal remain blocked.
Esta página también está disponible para…
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|