../pvss.htm menu.gif basics.gif

startThread()

Starts a function in a new thread.

Synopsis

Parameters

Return value

If the function could not be started, -1 is returned. If the function was started successfully and the thread stops immediately as well as in all other cases startThread() returns the thread identification number ThreadId (>= 0).

Errors

incorrect/invalid argument, ,for example, if the function to be started does not exist.

Description

Starts the function funcName as a new, parallel thread. Arguments can be transferred to the function with arg1, arg2, ... .

The function to be started can only be void, i.e. may have no return values.

IconEXAMPLE

Starts "test as a new thread.

main()

{

startThread("test");

}

 

void test()

{

...

}

IconEXAMPLE

Calls the function "myWorkFunction" and starts it a s a new thread.

main()

{

startThread("myWorkFunction", TRUE, 3); /* Output will be "3", "2", "1". Time between output is 1s */

}

 

void myWorkFunction(bool bNeedWait, int iIterations)

{

while (iIterations > 0)

{

Debug("Iteration: ",iIterations--);

if (bNeedWait)

{

delay(1);

}

}

}

Relates to

Threads

Availability

UI, CTRL, DP

See also

getThreadId(),  stopThread(), waitThread()

Top Of Page

 

V 3.11 SP1

Copyright ETM professional control GmbH 2013 All Rights Reserved