PC SOFT

ONLINE HELP
FOR WINDEV, WEBDEV AND WINDEV MOBILE

Home | Sign in | English US
  • Declaration
  • Using the AutomaticEvent variables
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 AutomaticEvent type is used to manage an automatic signal. An automatic signal is used to simplify the synchronization between several threads.
After its opening, an "Automatic" signal is automatically closed as soon as a single thread is unlocked.
Note: We recommend that you use an AutomaticEvent or ManualEvent variable to create a signal rather than naming it by using a character string. Indeed, using a variable allows you to:
  • manage the variable scope,
  • avoid having 2 signals with the same name in 2 different threads.
Versions 21 and later
Apple Watch This type of variable is now available in Apple Watch mode.
New in version 21
Apple Watch This type of variable is now available in Apple Watch mode.
Apple Watch This type of variable is now available in Apple Watch mode.
Example
// MAIN THREAD
//------------------
// Define the signal
s is AutomaticEvent
// Start the thread
ThreadExecute("Thread", threadNormal, ProcThread, s)

// Code in parallel of the thread
...
// Wait for the signal triggered by the thread
EventWait("s")
// SECONDARY THREAD
// ----------------------
PROCÉDURE ProcThread(s)

// Code in the thread
...
// Unlock the main thread
EventOpen(s)
Declaration

Declaring an automatic signal (simple syntax) Hide the details

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

Declaring an automatic signal (advanced syntax) Hide the details

MyVariable is AutomaticEvent(<Initial Status>)
<Initial Status>: Integer constant
Initial status of the signal:
eventOpenThe signal is opened when it is created.
eventCloseThe signal is closed during its creation.
Remarks

Using the AutomaticEvent variables

The AutomaticEvent variables can be used to synchronize threads between themselves in the functions:
Versions 20 and later
EventClose
New in version 20
EventClose
EventClose
Closes a synchronization signal between several threads.
Versions 20 and later
EventOpen
New in version 20
EventOpen
EventOpen
Opens a synchronization signal between several threads.
Versions 09 and later
EventWait
New in version 09
EventWait
EventWait
Locks the current thread while waiting for the specified signal to be opened.
During a call to EventOpen:
  • if there is at least one pending thread, a single thread is freed.
  • if there is no pending thread, the signal remains opened until a thread calls EventWait.
Minimum required version
  • Version 20
This page is also available for…
Comments
Click [Add] to post a comment