ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / WLanguage / WLanguage functions / Standard functions / Process functions / Threads, semaphores, signals and mutex
  • Operating mode
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
Triggers the execution of a procedure by the main application thread.
Example
// Interact with the user
AnAnswer is string
AnAnswer = ExecuteMainThread(UserInteractionProcedure, "Message")
Syntax
<Result> = ExecuteMainThread(<WLanguage procedure> [, <Parameter 1> [... [, <Parameter N>]]])
<Result>: Character string
Return value of the procedure called. This value is identical to the value obtained if the procedure is run directly.
<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).
Remarks

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 ExecuteMainThread, 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 ExecuteMainThread, 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 ExecuteMainThread 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 ExecuteMainThread.
The call to ExecuteMainThread is locking as long as the procedure was not run by the main thread.
Caution:
  • ExecuteMainThread 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 ExecuteMainThread is called.
Related Examples:
Using parallel tasks Unit examples (WINDEV): Using parallel tasks
[ + ] The parallel tasks are used to speed up the process times and to improve the reactivity of an application.
This example presents the functions and types of variables required to use the parallel tasks:
- running parallel tasks,
- interaction with the controls,
- continuation tasks.
Business / UI classification: Neutral code
Component: wd290wm.dll
Minimum version required
  • Version 17
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 06/30/2023

Send a report | Local help