Skip to content

Coroutines

Kevin Zhao edited this page Jan 25, 2018 · 2 revisions

Coroutines

Most other Lua embedding libraries do not properly support .NET bindings within coroutines. This problem is solved in Triton by relaxing the requirements of what state pointers can be used with a given Lua environment. Thus, the following will work perfectly:

lua.DoString(@"
    list = List(String)()
    co = coroutine.create(function()
        Console.WriteLine('test')
        x = coroutine.yield()
        list:Add(x)
        Console.WriteLine(x)
    end)

    coroutine.resume(co)
    coroutine.resume(co, 'test 2')
Clone this wiki locally