PC SOFT

ONLINE HELP
FOR WINDEV, WEBDEV AND WINDEV MOBILE

Home | Sign in | English US
  • Endless wait
  • Synchronizing the 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 the reception of a signal send by another thread. This function simplifies the synchronization between threads without having to implement an advanced management of signals.
Note: This function is equivalent to EventWait with an automatic signal for a signal sent by ThreadSendSignal. Therefore, the signal is automatically closed.
Reminders:
  • 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.
Versions 15 and later
Android This function is now available for the Android applications.
New in version 15
Android This function is now available for the Android applications.
Android This function is now available for the Android applications.
Versions 17 and later
Universal Windows 10 App This function is now available for the Windows Phone applications.
New in version 17
Universal Windows 10 App This function is now available for the Windows Phone applications.
Universal Windows 10 App This function is now available for the Windows Phone applications.
Versions 18 and later
Universal Windows 10 App This function is now available in Windows Store apps mode.
Android Widget This function is now available in Android Widget mode.
New in version 18
Universal Windows 10 App This function is now available in Windows Store apps mode.
Android Widget This function is now available in Android Widget mode.
Universal Windows 10 App This function is now available in Windows Store apps mode.
Android Widget This function is now available in Android Widget mode.
Versions 19 and later
iPhone/iPad This function is now available for the iPhone/iPad applications.
WEBDEV - Server codeLinux This function is now available for the WEBDEV sites in Linux.
WINDEVLinux This function is now available for the WINDEV applications in Linux.
New in version 19
iPhone/iPad This function is now available for the iPhone/iPad applications.
WEBDEV - Server codeLinux This function is now available for the WEBDEV sites in Linux.
WINDEVLinux This function is now available for the WINDEV applications in Linux.
iPhone/iPad This function is now available for the iPhone/iPad applications.
WEBDEV - Server codeLinux This function is now available for the WEBDEV sites in Linux.
WINDEVLinux This function is now available for the WINDEV applications in Linux.
Versions 21 and later
Apple Watch This function is now available in Apple Watch mode.
Universal Windows 10 App This function is now available in Universal Windows 10 App mode.
New in version 21
Apple Watch This function is now available in Apple Watch mode.
Universal Windows 10 App This function is now available in Universal Windows 10 App mode.
Apple Watch This function is now available in Apple Watch mode.
Universal Windows 10 App This function is now available in Universal Windows 10 App mode.
// Create a signal
EventCreate("Let's go", eventManual, eventClose)
// Run a first thread
ThreadExecute("Thread1", threadNormal, "Thread_First")
// Locks the current thread until the signal is obtained
ThreadWaitSignal()

// Run a second thread
ThreadExecute("Thread2", threadNormal, "Thread_Second")
// Locks the current thread until the signal is obtained
ThreadWaitSignal()

// Modifies the signal 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) + " - Signal received")
//--------------------------------------------
PROCÉDURE Thread_Second()
Trace(dbgInfo(dbgProcess) + " - ThreadSendSignal(threadMain)")
ThreadSendSignal(threadMain)
EventWait("Let's go")
Trace(dbgInfo(dbgProcess) + " - Signal received")
Syntax
<Result> = ThreadWaitSignal([<Maximum Time-out>])
<Result>: Boolean
  • True if the current thread received a signal,
  • False if the thread receives no signal (the maximum duration is exceeded).
<Maximum Time-out>: Optional integer, optional duration or optional constant
Maximum time-out 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 if it 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 have the ability to end the execution of a thread even if this one is locked in an endless wait for a signal. To do so, use ThreadStop.

Synchronizing the threads

ThreadWaitSignal and ThreadSendSignal are used to synchronize the threads two by two. To synchronize several threads on the same signal, the functions for signal management must be used:
Note: 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.
Components
WINDEVWEBDEV - Server codeReports and Queries wd230vm.dll
Windows Mobile wp230vm.dll
Java wd230java.jar
Linux wd230vm.so
Android wd230android.jar
Minimum required version
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment