sqlite in background

I’d like to do some relatively heavy data transformation (mostly inserts and updates) but I’d also would like to run an animation in the foreground (to indicate processing).

Unfortunately I can’t find a way to create an asynchronous method so that I can run both the sqlite initialization method and the loading animation (using sprite sheets).

Are there any lua/corona features I’m missing or any work around which I haven’t thought of?

Thanks [import]uid: 72951 topic_id: 14547 reply_id: 314547[/import]

@gryzlaw,

depends on what kind of animation, you can have a sprite animation that keeps looping forever and you can stop it when the SQL returns with some data.

the way would be to load the spritesheet and set the animation to loop forever, then run the SQL command and when it completes, then stop the animation.

cheers,

?:slight_smile: [import]uid: 3826 topic_id: 14547 reply_id: 53922[/import]

@jayantv,

That’s what I would have expected, but it didn’t work as I thought.

With this code:

  
 local spritext = require "spritext" -- tried also normal sprite animation  
  
 local loading = spritext.newAnim("loading.png", 60, 60, 1, 8);   
 loading.x = display.contentWidth / 2  
 loading.y = display.contentHeight / 2 - 30  
 loading:play()  
 localGroup:insert(loading)  
  
 local function initialise()  
 db.doInit() -- the databse inputs are here  
 director:changeScene( "intro")  
 end  
 timer.performWithDelay(500, initialise, 1)   
  

The result is a loading animation for 500ms than the application and the animation (seemingly) block, until the database inserts finish and the scene changes.

I’ve actually also tried to update the sprite (using loading:nextFrame()) after every insert, but that too did not update.

Any other ideas? [import]uid: 72951 topic_id: 14547 reply_id: 53940[/import]

Really, no ideas anyone? [import]uid: 72951 topic_id: 14547 reply_id: 54179[/import]

use coroutine Luck :slight_smile: [import]uid: 12704 topic_id: 14547 reply_id: 62042[/import]