PC SOFT

ONLINE HELP
FOR WINDEV, WEBDEV AND WINDEV MOBILE

Home | Sign in | English US
  • Overview
  • Simple management of signals
  • Principle
  • Example: Application managing a spelling checker
  • WLanguage functions
  • Note
  • Advanced management of signals
  • Principle
  • Implementation
  • The functions for advanced management of signals
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
Overview
The signals can be used to synchronize the different threads of an application. Therefore, a thread can wait for the execution of another thread.
Two management modes can be used to manage signals:
Versions 17 and later
Universal Windows 10 App This feature is now available for the Windows Phone applications.
New in version 17
Universal Windows 10 App This feature is now available for the Windows Phone applications.
Universal Windows 10 App This feature is now available for the Windows Phone applications.
Versions 19 and later
iPhone/iPad This feature is now available for the iPhone/iPad applications.
WINDEVLinux This feature is now available for the WINDEV applications in Linux.
WEBDEV - Server codeLinux This feature is now available for the WEBDEV sites in Linux.
New in version 19
iPhone/iPad This feature is now available for the iPhone/iPad applications.
WINDEVLinux This feature is now available for the WINDEV applications in Linux.
WEBDEV - Server codeLinux This feature is now available for the WEBDEV sites in Linux.
iPhone/iPad This feature is now available for the iPhone/iPad applications.
WINDEVLinux This feature is now available for the WINDEV applications in Linux.
WEBDEV - Server codeLinux This feature is now available for the WEBDEV sites in Linux.
Versions 21 and later
Universal Windows 10 App This feature is now available for the applications in Universal Windows 10 App mode.
New in version 21
Universal Windows 10 App This feature is now available for the applications in Universal Windows 10 App mode.
Universal Windows 10 App This feature is now available for the applications in Universal Windows 10 App mode.
Simple management of signals

Principle

Two threads are run in parallel (a main thread and a secondary thread for instance). One of the threads waits for a specific action from the second thread before it can be run.

Example: Application managing a spelling checker

When the user types the SPACE character in an edit control, the spelling checker is automatically started to check the previous word.
In this case, the spell check is managed in a secondary thread.
Whenever the SPACE key is pressed, the main thread sends a signal to the secondary thread in order to start the spelling checker.
The code for this kind of application is as follows:
  • Code of the main thread:
    IF Right(EDT_Edit1, 1) = " " THEN
    ThreadSendSignal("ThreadCorrection")
    END
  • Code of secondary thread (ThreadCorrection):
    LOOP
    IF ThreadWaitSignal() = True THEN
     StartCorrection()
    END
    END

WLanguage functions

The following functions are used to perform a simple management of signals:
Versions 09 and later
ThreadSendSignal
New in version 09
ThreadSendSignal
ThreadSendSignal
The current thread sends a signal to the specified thread in order to unlock it.
Versions 09 and later
ThreadWaitSignal
New in version 09
ThreadWaitSignal
ThreadWaitSignal
Locks the current thread until it receives a signal from another thread.

Note

The semaphores and the signals are system objects identified by their name. They are shared among all the applications that run on a computer.
Therefore, two applications (or two instances of the same application) use the same objects if the same name is used.
To create unique names, use Instance to implement the requested name.
Java In Java, the semaphores, the critical sections and the signals are unique for the application that created them. They cannot be shared between several applications.
Advanced management of signals

Principle

An advanced management of signals consists in communicating between several threads (more than 2). Some threads are waiting for a task performed by the main thread. When the main thread performs this task, it sends a signal to all the secondary threads.

Implementation

Two methods can be used to implement an advanced management of signals:
  • Versions 20 and later
    Using AutomaticEvent and ManualEvent.
    New in version 20
    Using AutomaticEvent and ManualEvent.
    Using AutomaticEvent and ManualEvent.
  • Using named signals (recommended method to manage the options for signal share).
Versions 20 and later
WINDEVWEBDEV - Server codeiPhone/iPadWindows MobileUniversal Windows 10 App Method 1: Using EventAutomatic and EventManual.
The steps for implementing an advanced management of signals are as follows:
  1. Creating an AutomaticEvent variable or a ManualEvent variable. By default, this signal is closed. The signal is automatically destroyed when going outside the range of the corresponding variable.
  2. Waiting for the signal (EventWait).
  3. Synchronizing the threads with EventOpen and EventClose.
New in version 20
WINDEVWEBDEV - Server codeiPhone/iPadWindows MobileUniversal Windows 10 App Method 1: Using EventAutomatic and EventManual.
The steps for implementing an advanced management of signals are as follows:
  1. Creating an AutomaticEvent variable or a ManualEvent variable. By default, this signal is closed. The signal is automatically destroyed when going outside the range of the corresponding variable.
  2. Waiting for the signal (EventWait).
  3. Synchronizing the threads with EventOpen and EventClose.
WINDEVWEBDEV - Server codeiPhone/iPadWindows MobileUniversal Windows 10 App Method 1: Using EventAutomatic and EventManual.
The steps for implementing an advanced management of signals are as follows:
  1. Creating an AutomaticEvent variable or a ManualEvent variable. By default, this signal is closed. The signal is automatically destroyed when going outside the range of the corresponding variable.
  2. Waiting for the signal (EventWait).
  3. Synchronizing the threads with EventOpen and EventClose.
Method 2: Using named signals (recommended method to manage the options for signal share)
The steps for implementing an advanced management of signals are as follows:
  1. Creating a signal (EventCreate). By default, this signal is closed.
  2. Waiting for the signal (EventWait).
  3. Synchronizing threads:
  4. Destroying the signal (EventDestroy).

The functions for advanced management of signals

The following functions are used to perform an advanced management of signals:
Versions 09 and later
EventChange
New in version 09
EventChange
EventChange
Modifies the status of a signal.
Versions 20 and later
EventClose
New in version 20
EventClose
EventClose
Closes a synchronization signal between several threads.
Versions 09 and later
EventCreate
New in version 09
EventCreate
EventCreate
Creates a signal.
Versions 09 and later
EventDestroy
New in version 09
EventDestroy
EventDestroy
Explicitly destroys a signal.
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.
Minimum required version
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment