ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / WLanguage / WLanguage functions / Standard functions / Process functions / Threads, semaphores, signals and mutex
  • Synchronizing threads
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
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
// Create an event
EventCreate("Let's go", eventManual, eventClose)
// Run a first thread
Thread1 is Thread(Thread_First)
ThreadExecute(Thread1)
// Locks the current thread until the event is obtained
ThreadWaitSignal()
 
// Run a second thread
Thread2 is Thread(Thread_Second)
ThreadExecute(Thread2)
// Locks the current thread until the event is obtained
ThreadWaitSignal()
 
// Modifies the event to run the threads
EventChange("Let's go", eventOpen)
//----------------------------------------------
PROCÉDURE Thread_First()
Trace(dbgInfo(dbgProcess) + " - ThreadSendSignal(threadMain)")
ThreadSendSignal(threadMain)
EventWait("Let's go")
Trace(dbgInfo(dbgProcess) + " - Event received")
//--------------------------------------------
PROCÉDURE Thread_Second()
Trace(dbgInfo(dbgProcess) + " - ThreadSendSignal(threadMain)")
ThreadSendSignal(threadMain)
EventWait("Let's go")
Trace(dbgInfo(dbgProcess) + " - Event received")
Syntax
WINDEVWEBDEV - Server codeUniversal Windows 10 AppiPhone/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 management functions must be used:
Remark: The internal mechanisms for managing the queues and stacks allow you not to synchronize the threads (<Queue variable>.Enqueue and <Queue variable>.Dequeue for the queues, <Stack variable>.Push and <Stack variable>.Pop for the stacks).
Business / UI classification: Neutral code
Component: wd290vm.dll
Minimum version required
  • Version 25
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 06/21/2023

Send a report | Local help