New WINDEV and WINDEV Mobile 28 feature!
Help / WLanguage / WLanguage functions / Standard functions / Process management functions / Threads, semaphores, signals and mutex
  • Operating mode
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WindowsLinuxPHPWEBDEV - Browser code
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Stored procedures
Executes a procedure in the main thread of the application without waiting for the end of its execution.
// From a secondary thread, interact with the user
ExecuteMainThreadAsynchronous(UserInteractionProcedure, "Message")
ExecuteMainThreadAsynchronous(<WLanguage procedure> [, <Parameter 1> [... [, <Parameter N>]]])
<WLanguage procedure>: Procedure name
Name of procedure to execute.
<Parameter 1>: Optional
Parameters that will be passed to the procedure. Caution: these parameters are passed by value (not by reference).
<Parameter N>: Optional
Parameters that will be passed to the procedure. Caution: these parameters are passed by value (not by reference).

Operating mode

The main thread executes the procedure when it waits for user actions.
Therefore, when the main thread of an application needs to execute procedures called by ExecuteMainThreadAsynchronous, the following rules must be complied with:
  • the main thread must be highly available: critical sections must be short and localized, there must be no long processes if a secondary thread needs to call ExecuteMainThreadAsynchronous, there must be no semaphores or events that wait for synchronization objects.
  • to avoid deadlocks, threads must not hold synchronization objects (critical sections, semaphores, events, etc.) when ExecuteMainThreadAsynchronous is called.
If the main thread is executing a process, it is not interrupted and the procedure is executed when the main thread waits for a user action again.
However, Multitask can be used to interrupt a long process to handle the user actions and execute the procedures called by ExecuteMainThreadAsynchronous.
The call to ExecuteMainThreadAsynchronous is non-blocking: the rest of the code is executed regardless of whether the procedure has already been executed by the main thread. The return value of the procedure cannot be retrieved.
  • ExecuteMainThreadAsynchronous cannot be used to call a procedure from a "parent" execution context. For example, a project procedure cannot be called from an external component.
  • The details of the errors and exceptions from the executed procedure are retrieved in the calling thread where ExecuteMainThreadAsynchronous is called.
Component: wd280vm.dll
Minimum version required
  • Version 28
This page is also available for…
Click [Add] to post a comment

Last update: 06/26/2023

Send a report | Local help