AYUDA EN LÍNEA
 WINDEVWEBDEV Y WINDEV MOBILE

Este contenido se ha traducido automáticamente.  Haga clic aquí  para ver la versión en inglés.
Ayuda / WLanguage / Funciones WLanguage / Funciones estándar / Funciones de gestión de procesos / Hilos, semáforos, señales y mutex
  • Synchronizing threads
WINDEV
WindowsLinuxJavaReportes y ConsultasCódigo de Usuario (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Código Navegador
WINDEV Mobile
AndroidWidget Android iPhone/iPadIOS WidgetApple WatchMac Catalyst
Otros
Procedimientos almacenados
The current thread sends an event to the specified thread in order to unlock it. This function simplifies the synchronization between threads without having to implement an advanced management of events.
Reminder:
  • A thread is a process run in parallel with the current application (main thread). This allows you to run a task in the background (e.g. backup, etc.).
  • ThreadWaitSignal and ThreadSendSignal are used to synchronize the threads two by two.
// Create an event
EventCreate("Let's go", eventManual, eventClose)
// Run a first thread
ThreadExecute("Thread1", threadNormal, "Thread_First")
// Locks the current thread until the event is obtained
ThreadWaitSignal()

// Run a second thread
ThreadExecute("Thread2", threadNormal, "Thread_Second")
// Locks the current thread until the event is obtained
ThreadWaitSignal()

// Modifies the event to run the threads
EventChange("Let's go", eventOpen)
//----------------------------------------------
PROCEDURE Thread_First()
Trace(dbgInfo(dbgProcess) + " - ThreadSendSignal(threadMain)")
ThreadSendSignal(threadMain)
EventWait("Let's go")
Trace(dbgInfo(dbgProcess) + " - Event received")
//--------------------------------------------
PROCEDURE Thread_Second()
Trace(dbgInfo(dbgProcess) + " - ThreadSendSignal(threadMain)")
ThreadSendSignal(threadMain)
EventWait("Let's go")
Trace(dbgInfo(dbgProcess) + " - Event received")
Sintaxis

Sending a signal to a thread identified by its name Ocultar los detalles

ThreadSendSignal(<Thread name>)
<Thread name>: Character string
Name of the thread to which the event must be sent. To send an event to the main thread, use the character string "." or the threadMain constant.
No event can be sent to the current thread.
This name is given when running the thread (ThreadExecute).
WINDEVWEBDEV - Código ServidoriPhone/iPadIOS WidgetApple WatchMac Catalyst

Sending a signal to a thread identified by a Thread variable Ocultar los detalles

ThreadSendSignal(<Thread>)
<Thread>: Thread variable
Name of the Thread variable corresponding to the thread to which the signal must be sent. To send an event to the main thread, use the character string "." or the threadMain constant.
No event can be sent to the current thread.
Observaciones

Synchronizing threads

ThreadWaitSignal and ThreadSendSignal are used to synchronize the threads two by two. To synchronize several threads on the same event, the event functions must be used:
Note: Internal queue and stack management mechanisms eliminate the need for thread synchronization (functions Enqueue and Dequeue for queues, functions Push and Pop for stacks).
Clasificación Lógica de negocio / UI: Código neutro
Componente: wd300vm.dll
Versión mínima requerida
  • Versión 9
Esta página también está disponible para…
Comentarios
Haga clic en [Agregar] para publicar un comentario

Última modificación: 27/03/2025

Señalar un error o enviar una sugerencia | Ayuda local