ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / WLanguage / WLanguage functions / Standard functions / Process functions / Threads, semaphores, signals and mutex
  • Synchronizing threads
WINDEV
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
Others
Stored procedures
The current thread sends an event to the specified thread in order to unlock it. This function simplifies the synchronization between threads without having to implement an advanced management of events.
Reminder:
  • 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 <Thread>.SendSignal are used to synchronize the threads two by two.
Example
// Création d'un signal
EventCreate("Allez-y", eventManual, eventClose)
// Exécution d'un premier thread
Thread1 is Thread(Thread_Premier)
ThreadExecute(Thread1)
// Bloque le thread en cours jusqu'à l'obtention du signal
ThreadWaitSignal()

// Exécution d'un second thread
Thread2 is Thread(Thread_Second)
ThreadExecute(Thread2)
// Bloque le thread en cours jusqu'à l'obtention du signal
ThreadWaitSignal()

// Modifie le signal pour exécuter les threads
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
WINDEVWEBDEV - Server codeiPhone/iPadIOS WidgetApple WatchMac Catalyst

Sending a signal to a thread identified by a Thread variable Hide the details

<Thread>.SendSignal()
<Thread>: Thread variable
Name of the Thread variable corresponding to the thread to which the signal must be sent.
Remarks

Synchronizing threads

ThreadWaitSignal and <Thread>.SendSignal 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 <Queue variable>.Enqueue and <Queue variable>.Dequeue for queues, functions <Stack variable>.Push and <Stack variable>.Pop for stacks).
Business / UI classification: Neutral code
Component: wd300vm.dll
Minimum version required
  • Version 25
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 09/26/2024

Send a report | Local help