WaitThread()

Syntax

Result = WaitThread(Thread [, Timeout])
Description
Stop the program execution until the specified 'Thread' exits, or the optional timeout (in milliseconds) is reached. If the thread is already finished, it returns immediately.

Parameters

Thread - The number of the thread you want to wait for. This value is returned by CreateThread().
Timeout - optional timeout to wait in miliseconds.

Return value

If the thread has ended, the returnvalue is nonzero. Zero is returned if the timeout was reached.

Example:

  Procedure PrintStuff(*Interval)
    For i = 0 To 10
      PrintN(".")
      Delay(*Interval)
    Next
  EndProcedure
  
  If OpenConsole()
    thread = CreateThread(@PrintStuff(), 500)
    If thread
      ; Wait for thread to finish before we continue
      ; Try commenting the WaitThread function out and seeing what happens
      WaitThread(thread)
      
      For i = 0 To 10
        PrintN("A")
        Delay(1000)
      Next
    EndIf
  EndIf

Supported OS

All

<- WaitSemaphore() - Thread Index