PC SOFT

WINDEVWEBDEV AND WINDEV MOBILE
ONLINE HELP

  • Example: Communication between 2 threads
ThreadWaitSignal (Example)
Example: Communication between 2 threads
WINDEVWindowsJavaUser code (UMC) The following example is used communicate between two threads via ThreadWaitSignal and ThreadSendSignal.
// -- Initialization code of project
GLOBAL
gnAction is int

// Runs the thread1
ThreadExecute("Thread1", threadNormal, ProcThread1)

// Runs the thread2
ThreadExecute("Thread2", threadNormal, ProcThread2)

// Waits for the end of Thread1 before continuing the program execution
ThreadWait("Thread1")
PROCEDURE ProcThread1()
bContinue is boolean = True
WHILE bContinue
ThreadWaitSignal()
SWITCH gnAction
CASE 1:
// <Process of action 1>
CASE 2:
// <Process of action 2>
OTHER CASE: bContinue = False
END
ThreadSendSignal("Thread2")
END

// End of Thread2
ThreadStop("Thread2")
PROCÉDURE ProcThread2()
...
// <Code>
...
gnAction = 1
ThreadSendSignal("Thread1")
ThreadWaitSignal()
...
// <Code>
...
gnAction = 2
ThreadSendSignal("Thread1")
ThreadWaitSignal()
...
// <Code>
...
gnAction = 3
ThreadSendSignal("Thread1")
ThreadWaitSignal()
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment