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.
WEBDEV - Server code Caution: This function has no effect in WEBDEV sites (Windows or Linux).
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 procedure called. This value is identical to the value obtained if the procedure is run directly.
<WLanguage procedure>: Procedure name
Name of procedure to run.
<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 procedure execution is performed by the main thread when this one is waiting for interactions with the user.
Therefore, when the main application thread must run procedures called by ExecuteMainThread, the following rules must be complied with:
  • the main thread must be highly available: sort and localized critical sections, no long process when a secondary thread may have to call ExecuteMainThread, no wait for synchronization objects (semaphores, events, etc.).
  • the call to ExecuteMainThread from the threads must be done without "keeping" synchronization objects (critical sections, semaphores, events, ...) to avoid a deadlock.
If the main thread is running a process, this process is not interrupted and the procedure will be run when the main thread switches back to waiting for interaction with the user.
However, Multitask allows you to interrupt a long process in order to process the user actions and to run 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 of "parent" execution context. For example, a project procedure cannot be called from an external component.
  • The errors and the exceptions coming from the procedure run are carried over to the calling thread during the call to ExecuteMainThread.
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: wd270wm.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