Hi guys,
i've a problem.
I've this in the Activity_Create
B4X:
Dim r As ResultSet = Starter.FileManager1.SQL1.ExecQuery("SELECT RowID FROM xxx")
If r.RowCount < 7903 Then 'se il DB è vuoto
Wait For (CallSub2(HeavyTasks, "Add", Array As Object("xxx", "ALL", True))) Complete
End If
r.Close
Then, in the Service Module named "HeavyTasks" i've this:
B4X:
Public Sub Add(Params() As Object) As ResumableSub
'Type 0, Input 1, Sync 2
queue.Add(CreateMap("Tipo":Params(0), "Input":Params(1)))
Log(queue)
If Not(Downloading) Then
Wait For (DownloadDB(Params(2))) Complete (r As Boolean)
End If
Return r
End Sub
Public Sub DownloadDB(Sync As Boolean) As ResumableSub
... do things ...
Return True
End Sub
The problem is that the "Add" sub in the HeavyTasks module is NEVER fired, and the app deadlock there...
If i use CallSubDelayed it works, but i can't use waitfor...
1. Everything will be simpler if you use B4XPages.
2. What exactly are you doing in the "heavy task"?
3. Why are you doing it in a service? It will not have any effect on the performance.
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...