-
Notifications
You must be signed in to change notification settings - Fork 1
Threads
Kevin Zhao edited this page Jan 29, 2018
·
3 revisions
Threads (or technically, fibers) can be created using the CreateThread
function, which requires a LuaFunction
argument as the function for the thread to run:
var function = lua.LoadString(@"
print('test')
local x = coroutine.yield()
print('val: ' .. x)
local y = coroutine.yield()
print('val 2: ' .. y)");
The resulting thread can then be resumed using the Resume
method, so long as CanResume
is true.
LuaThread
s support dynamic access:
dynamic thread = (LuaThread)lua.DoString("return coroutine.create(function() return 4 end)")[0];
Assert.Equal(4L, thread());