PC SOFT

WINDEVWEBDEV AND WINDEV MOBILE
ONLINE HELP

Home | Sign in | English UK
  • Endless wait
  • Synchronizing threads
  • Various
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
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.
Remark: This function is equivalent to EventWait with an automatic event for a signal sent by ThreadSendSignal. Therefore, the event is automatically closed.
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.
Versions 19 and later
WEBDEV - Server codeLinux This function is now available for WEBDEV sites in Linux.
Linux This function is now available for WINDEV applications in Linux.
New in version 19
WEBDEV - Server codeLinux This function is now available for WEBDEV sites in Linux.
Linux This function is now available for WINDEV applications in Linux.
WEBDEV - Server codeLinux This function is now available for WEBDEV sites in Linux.
Linux This function is now available for WINDEV applications in Linux.
// 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
<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,
  • Versions 23 and later
    the direct indication of duration (1 s or 10 ms for example).
    New in version 23
    the direct indication of duration (1 s or 10 ms for example).
    the direct indication of duration (1 s or 10 ms for example).
Remarks

Endless wait

You can end the execution of a thread even if it is locked in an endless wait for an event. To do so, use ThreadStop.

Synchronizing 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).

Various

ThreadWaitSignal can be used in a process linked to a control (click code of a button for example): in this case, it is used in the main thread.
Component : wd250vm.dll
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment