CreateThread()

Syntax

Thread = CreateThread(@ProcedureName(), Value)
Description
Creates a new thread running in the application background. If the thread is correctly created, it returns the Thread number which is used with the other thread commands, such as KillThread(), PauseThread(), etc. The procedure which you use as a thread must take one parameter and cannot return anything. The 'Value' argument of CreateThread() is passed as the parameter to the procedure. If you do try to return a value from your thread it will simply be lost.

Parameters

@procedurename()- The address of the procedure you want to use as the code for the new thread. Remember to put the @ in front to get the name and the () afterwards so it gets the address of the procedure.

Value - This is passed to the thread code as the parameter to your function. It is up to you to decide what this is used for.

Return value

The number for the newly created thread, or zero if a new thread could not be created. This number is required if you want to control the thread using the other commands in this library.

Example:

The example below shows the basic way to create a thread, although in this case it does not do anything.

  Procedure YourProcedure(Value)
    ; The variable 'Value' will contain 23
  EndProcedure

  CreateThread(@YourProcedure(), 23)

Supported OS

All

<- CreateMutex() - Thread Index - FreeMutex() ->