PC SOFT

WINDEVWEBDEV AND WINDEV MOBILE
ONLINE HELP

Home | Sign in | English UK
  • Synchronizing the threads
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadApple WatchUniversal Windows 10 AppWindows Mobile
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 of current application (main thread). This allows you to run a task in background task for example (backup, ...).
  • ThreadWaitSignal and ThreadSendSignal are used to synchronize the threads two by two.
// Create an event
EventCreate("Let's go", eventManual, eventClose)
// Run a first thread
ThreadExecute("Thread1", threadNormal, "Thread_First")
// Locks the current thread until the event is obtained
ThreadWaitSignal()
 
// Run a second thread
ThreadExecute("Thread2", threadNormal, "Thread_Second")
// Locks the current thread until the event is obtained
ThreadWaitSignal()
 
// Modifies the event to run the threads
EventChange("Let's go", eventOpen)
//----------------------------------------------
PROCEDURE Thread_First()
Trace(dbgInfo(dbgProcess) + " - ThreadSendSignal(threadMain)")
ThreadSendSignal(threadMain)
EventWait("Let's go")
Trace(dbgInfo(dbgProcess) + " - Event received")
//--------------------------------------------
PROCEDURE Thread_Second()
Trace(dbgInfo(dbgProcess) + " - ThreadSendSignal(threadMain)")
ThreadSendSignal(threadMain)
EventWait("Let's go")
Trace(dbgInfo(dbgProcess) + " - Event received")
Syntax

Sending a signal to a thread identified by its name Hide the details

ThreadSendSignal(<Thread name>)
<Thread name>: Character string (with quotes)
Name of the thread to which the event must be sent. To send an event to the main thread, use the character string "." or the threadMain constant.
No event can be sent to the current thread.
This name is given when running the thread (ThreadExecute).
Remarks

Synchronizing the threads

ThreadWaitSignal and ThreadSendSignal 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 (Enqueue and Dequeue for the queues, Push and Pop for the stacks).
Business / GUI classification : Neutral code
Component : wd250vm.dll
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment