Tao.Lua SDK Documentation

Lua.lua_resume Method 

Starts and resumes a coroutine in a given thread.

[Visual Basic]
Public Shared Function lua_resume( _
   ByVal L As IntPtr, _
   ByVal narg As Integer _
) As Integer
[C#]
public static int lua_resume(
   IntPtr L,
   int narg
);

Parameters

L
narg

Return Value

When it returns, the stack contains all values passed to lua_yield, or all values returned by the body function. lua_resume returns LUA_YIELD if the coroutine yields, 0 if the coroutine finishes its execution without errors, or an error code in case of errors (see lua_pcall). In case of errors, the stack is not unwound, so you can use the debug API over it. The error message is on the top of the stack.

Remarks

To start a coroutine, you first create a new thread (see lua_newthread); then you push onto its stack the main function plus any arguments; then you call lua_resume, with narg being the number of arguments. This call returns when the coroutine suspends or finishes its execution. To restart a coroutine, you put on its stack only the values to be passed as results from yield, and then call lua_resume.

See Also

Lua Class | Tao.Lua Namespace