Hi everyone, I've an app that need to download an huge dataset.
We are talking about making a http request the return a json of 8000 rows, that need to be stored in a local SQL DB in the device.
Now.. the problem is the following: downloading and storing all the rows in the DB takes a while, and I don't want the user to wait until the process finishes, because it is not essential, and it could become long.
So the logical solution is: "do it in background" ok... It is what I want to do, but even if I avoid to use the "wait for" the app still freezes (to prevent freezing I put a "sleep(0)" but it slows down a lot) because is inserting all the rows in the DB.
So.. I think that the right way to do it is entrust the work to a separate thread, in this way it will manage ONLY that part, leaving the rest of the work to the main thread.
The problem at this point is: is possible to use multithreading in B4A? if yes, how?
or maybe this is not the best solution.. I don't know
I found this in the forum:
Is this the right way in 2021? or something has changed?
Thanks in advance for you tips
We are talking about making a http request the return a json of 8000 rows, that need to be stored in a local SQL DB in the device.
Now.. the problem is the following: downloading and storing all the rows in the DB takes a while, and I don't want the user to wait until the process finishes, because it is not essential, and it could become long.
So the logical solution is: "do it in background" ok... It is what I want to do, but even if I avoid to use the "wait for" the app still freezes (to prevent freezing I put a "sleep(0)" but it slows down a lot) because is inserting all the rows in the DB.
So.. I think that the right way to do it is entrust the work to a separate thread, in this way it will manage ONLY that part, leaving the rest of the work to the main thread.
The problem at this point is: is possible to use multithreading in B4A? if yes, how?
or maybe this is not the best solution.. I don't know
I found this in the forum:
Threading library
This library lets you run Basic4android Subs on separate threads to the main GUI thread. It also contains a Lock (semaphore) object that can be used for resource access arbitration and thread synchronisation. Included is also an enhanced Exception object to give more information on any...
www.b4x.com
Is this the right way in 2021? or something has changed?
Thanks in advance for you tips