steve64 What's the preferred way to run a task concurrent to the GUI main loop with LuaRT ? So far I tried with something like: while win.visible do ui.update() --> do something else here end but I'm wondering if there is a better way, e.g. coroutines...
Samir You are right, inside the ui.update() loop is the simplest method to do other things. You can use some coroutine magic to prevent the program from becoming paralyzed. Look at the binary.wlua example that uses this method to prevent the Window to hang while reading big files.
steve64 Now I have a specific need: run a periodic task every N seconds while the main GUI event loop is processing its stuff as usual. I create a coroutine but If I put a delay inside it, the entire window is affected by delayed events. Is there any suggestion to manage such periodic subtasks? The subtask just does few operations that can yield, but how to apply a delay?
Samir The best way to achieve this is to put your work in the ui.update(delay) loop and provide a delay parameter for the ui.update function, this will process events until the time provided in milliseconds has elapsed.
steve64 I need to build an app that works at the same time as a GUI and as a TCP socket server (handling multiple clients). Can I do this with LuaRT 1.7.1 ? If so, what's the suggested way to structure the GUI event loop and the server initialization + message loop? I tried something with Task objects but so far no good results.
Samir Yes you can do it concurrently without blocking the GUI by using a non blocking net.Socket object. Non blocking Socket returns a Task object for recv/send operations. See examples\net\chatclient.wlua for an implementation example
steve64 Thanks! Looking at the examples, especially net\server.wlua, was great and I'm now able to run my GUI with background multi-client server...