waitThread
Top  Previous  Next

waitThread ( integer ID1 [,integer ID2,… ] )

Use this function to pause execution of the script until one or several threads terminate. Used to synchronize a multithreading script.

Parameters
 
ID1, ID2, …  
 
Positive integers specifying the IDs of the threads that must end in order for the function to return.  
 
Error flags
 
ERR_OK  
 
The flag set if successful.  
 
ERR_FAILED  
 
The flag set if failed.  
 
Example
 
This set of statements continuously captures an image and performs its processing in three parallel threads. The waitThread function at the end of the loop waits for two additional threads to complete, preventing the script from starting a new cycle before the processing is finished.  
 
do  
grabim(0)  
emphasize(0,1,10)  
'next two functions are executed in   
'separate threads  
a=thread("Emboss(0,3,1)")  
b=thread("Sobel(0,2,0)")  
'wait for both threads to complete  
waitThread(a,b)  
loop