ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / WLanguage / WLanguage functions / Standard functions / Process functions / Threads, semaphores, signals and mutex
  • Declaration
  • Using the AutomaticEvent variables
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 AutomaticEvent type is used to manage an automatic event. An automatic event is used to simplify the synchronization between several threads.
After its opening, an "Automatic" event is automatically closed as soon as a single thread is unlocked.
Remark: We recommend that you use an AutomaticEvent or ManualEvent variable to create an event rather than naming it using a character string. Indeed, using a variable allows you to:
  • manage the variable scope,
  • avoid having 2 events with the same name in 2 different threads.
Example
// MAIN THREAD
//------------------
// Define the event
s is AutomaticEvent
// Start the thread
ThreadExecute("Thread", threadNormal, ProcThread, s)
 
// Code in parallel with the thread
...
// Wait for the event triggered by the thread
EventWait("s")
// SECONDARY THREAD
// ----------------------
PROCEDURE ProcThread(s)
 
// Code in the thread
...
// Unlock the main thread
EventOpen(s)
Declaration

Declaring an automatic event (simple syntax) Hide the details

MyVariable is AutomaticEvent
In this case, the automatic event is closed when it is created.

Declaring an automatic event (advanced syntax) Hide the details

MyVariable is AutomaticEvent(<Initial state>)
<Initial state>: Integer constant
Initial state of the event:
eventOpenThe event is open when it is created.
eventCloseThe event is closed when it is created.
Remarks

Using the AutomaticEvent variables

The AutomaticEvent variables can be used to synchronize threads in functions:
Minimum version required
  • Version 20
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 06/21/2023

Send a report | Local help