WaitForThread() ... Simple and Easy.
Posted: Sat Feb 25, 2006 7:15 pm
Code updated For 5.20+
During my use of the hazard threading section of PB, there are times where I have to wait until a thread is finished before the program continues. Granted, at first, you may think, hey! Just use procedures ... however ...
Say you started a thread in the beginning of the program (such as listening on a certian port), and it runs during the course of your program, then during shutdown, you need to set the thread's shutdown flag, and then wait for the thread to shut down .... this code would be useful as you wouldnt want any thread leaks ...
Use:
During my use of the hazard threading section of PB, there are times where I have to wait until a thread is finished before the program continues. Granted, at first, you may think, hey! Just use procedures ... however ...
Say you started a thread in the beginning of the program (such as listening on a certian port), and it runs during the course of your program, then during shutdown, you need to set the thread's shutdown flag, and then wait for the thread to shut down .... this code would be useful as you wouldnt want any thread leaks ...
Code: Select all
Procedure WaitForThread(Thread.l, Wait.l)
Repeat
Delay(Wait)
Until IsThread(Thread) = #False
EndProcedure
Code: Select all
WaitForThread(Thread, 100)