WaitThread()

Syntax

WaitThread(ThreadID)
Description
Stop the program execution until the specified 'ThreadID' exits. If the thread is already finished, it returns immediately.

Parameters:
ThreadID - The ID number of the thread you want to wait for. This value is returned by CreateThread().


Return value:
This command does not return a value.


Example:
Procedure PrintStuff(interval.l)
    For i.w=0 To 10
        Print(".")
        Delay(interval)
    Next
EndProcedure

If OpenConsole()
    thid.l = CreateThread(@PrintStuff(), 500)
    If thid
        ; Wait for thread to finish before we continue
        ; Try commenting the WaitThread command out and seeing what happens
        WaitThread(thid)
        
        For i.w=0 To 10
            Print("A")
            Delay(1000)
        Next
    EndIf
EndIf
End

Supported OS

Windows, Linux, MacOS X

<- ThreadPriority() - Thread Index