Is it possible to do multiple/concurrent file downloading in Corona? Is there any sample code/recommendations available on technique? Or is it something that is not recommended?
The network.download() functions allows concurrent downloading.
FYI, I’ve found that when downloading a large number of photos, the downloads all finish in a small window of time. When this happens, the app appears to freeze as it processes/saves all the images.
thanks - so I guess it’s not true concurrency then do you think? you code running at the time blocks do you think? (as opposed to just a busy CPU on the device)
Let me try to clarify what I meant.
When you call network.download you supply a name of a listener function that gets called when the download completes.
You can call network.download in a loop and start the concurrent download of lots of images. This will not impact the performance of your app.
When each download completes, the listener function will get called. This is where you have to be careful. if 30 downloads finish at almost the same time, this function will get called 30 times. If you’re trying to do to much here, or the code is not optimized, it will feel like the app freezes or the frame rate will drop.
The network.download() functions allows concurrent downloading.
FYI, I’ve found that when downloading a large number of photos, the downloads all finish in a small window of time. When this happens, the app appears to freeze as it processes/saves all the images.
thanks - so I guess it’s not true concurrency then do you think? you code running at the time blocks do you think? (as opposed to just a busy CPU on the device)
Let me try to clarify what I meant.
When you call network.download you supply a name of a listener function that gets called when the download completes.
You can call network.download in a loop and start the concurrent download of lots of images. This will not impact the performance of your app.
When each download completes, the listener function will get called. This is where you have to be careful. if 30 downloads finish at almost the same time, this function will get called 30 times. If you’re trying to do to much here, or the code is not optimized, it will feel like the app freezes or the frame rate will drop.