Delaying a while loop in a coroutine.

Hi All,

I am usually a C programmer, very new to lua, very new to corona, and for some reason I have been pulled onto a project in the very late stage to help them with some functionality (I was doing the server backend, but they need help with the front end now too), and I am trying to work out how I would do the following.

I need to create something like a background thread that runs across scenes that makes a http request every 2 minutes.

The main issue I am finding right now is trying to find a way of putting a delay in the loop that will work even if the application is suspended (or backgrounded by android/ios). From my understanding, timer.performWithDelay() does not operate when the application is backgrounded.

In C I would basically thread a function that makes the request, then waits for 2000ms, in a while loop. Being very new to lua, and corona, I have been dumped in the deep end. Hope someone has some advice for me.

Thanks in advance,

Ryan

As far as I’ve understood, Corona does not support having the app running in the background (or the app running while suspended).

coroutines are sequential, not concurrent, so can’t create the type of “background thread” you wish.  and suspended means suspended, including all lua execution, including coroutines.  you’d have to go at least as deep as java to create a separate thread.

As far as I’ve understood, Corona does not support having the app running in the background (or the app running while suspended).

coroutines are sequential, not concurrent, so can’t create the type of “background thread” you wish.  and suspended means suspended, including all lua execution, including coroutines.  you’d have to go at least as deep as java to create a separate thread.