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 thread to wait for. This value is returned by CreateThread().
Timeout (optional) Timeout to wait, in milliseconds.

Return value

Nonzero if the thread has ended, or zero 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