0% found this document useful (0 votes)
7 views1 page

Lua Async Programming Example

The document contains Lua code utilizing the LibAsync library for asynchronous programming. It defines functions to print 'Hello' and 'World', and demonstrates the use of asynchronous tasks to iterate through numbers and pairs, printing their values. The code showcases the chaining of asynchronous calls and nested loops for handling multiple tasks concurrently.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views1 page

Lua Async Programming Example

The document contains Lua code utilizing the LibAsync library for asynchronous programming. It defines functions to print 'Hello' and 'World', and demonstrates the use of asynchronous tasks to iterate through numbers and pairs, printing their values. The code showcases the chaining of asynchronous calls and nested loops for handling multiple tasks concurrently.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

local async = LibStub("LibAsync")

local i=1
local function Hello() d("Hello") end
local function World() d("World") end

async:Call(function(task)
d(i)
task:Call(Hello):Then(World)
i = i + 1
return i<1000
end):Then(function() d("end") end)

-----------------------------------------------------------------------
local async = LibStub("LibAsync")

async:For (1,10):Do(function(index) d(index) end):Then(


function()
async:For (pairs({"a", "b"})):Do(function(key, value) d(key,value)
async:For (pairs({"c", "d"})):Do(function(key, value) d(key,value) end)
end)
end):For(11,15):Do(function(index) d(index) end)

You might also like