|
|
|
|
|
- Endless wait
- Synchronizing threads
- Miscellaneous
ThreadWaitSignal (Function) In french: ThreadAttendSignal Locks the current thread until it receives a signal from another thread. This function simplifies the synchronization between threads without having to implement an advanced management of events. Remarks: - This function is equivalent to EventWait with an automatic event for a signal sent by ThreadSendSignal. Therefore, the event is automatically closed.
- Blocking stops immediately (without waiting for the maximum duration) if a request to stop the thread is made by another thread using the ThreadRequestStop function.
Reminders: - A thread is a process run in parallel with the current application (main thread). This allows you to run a task in the background (e.g. backup, etc.).
- ThreadWaitSignal and ThreadSendSignal are used to synchronize the threads two by two.
EventCreate("Allez-y", eventManual, eventClose)
ThreadExecute("Thread1", threadNormal, "Thread_Premier")
ThreadWaitSignal()
ThreadExecute("Thread2", threadNormal, "Thread_Second")
ThreadWaitSignal()
EventChange("Allez-y", eventOpen)
PROCEDURE Thread_Premier()
Trace(dbgInfo(dbgProcess) + " - ThreadEnvoieSignal(threadPrincipal)")
ThreadSendSignal(threadMain)
EventWait("Allez-y")
Trace(dbgInfo(dbgProcess) + " - Signal reçu")
PROCEDURE Thread_Second()
Trace(dbgInfo(dbgProcess) + " - ThreadEnvoieSignal(threadPrincipal)")
ThreadSendSignal(threadMain)
EventWait("Allez-y")
Trace(dbgInfo(dbgProcess) + " - Signal reçu")
Syntax
<Result> = ThreadWaitSignal([<Maximum timeout>])
<Result>: Boolean - True if the current thread received a signal,
- False if the thread receives no signal (the maximum duration is exceeded).
<Maximum timeout>: Optional integer, optional duration or optional constant Maximum timeout in hundredths of a second. - If no signal was received by the thread before the end of specified duration, <Result> is equal to False.
- If this parameter is not specified or corresponds to the Infinite constant, the wait is infinite.
This parameter can correspond to: - an integer corresponding to the number of hundredths of a second,
- a Duration variable,
- the duration in a readable format (e.g., 1 s or 10 ms).
Remarks You can end the execution of a thread even if it is locked in an endless wait for an event. Simply use ThreadStop. ThreadWaitSignal and ThreadSendSignal are used to synchronize the threads two by two. To synchronize several threads on the same event, the event functions must be used: Note: Internal queue and stack management mechanisms eliminate the need for thread synchronization (functions Enqueue and Dequeue for queues, functions Push and Pop for stacks).. The ThreadWaitSignal function can be used in processing linked to a field (button click code, for example): it is then used in the main thread.
This page is also available for…
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|