M Mike1970 Well-Known Member Licensed User Longtime User Mar 1, 2021 #1 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... Thanks in advance
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... Thanks in advance
Erel B4X founder Staff member Licensed User Longtime User Mar 1, 2021 #2 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. Upvote 0
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.
M Mike1970 Well-Known Member Licensed User Longtime User Mar 1, 2021 #3 Erel said: Everything will be simpler if you use B4XPages. Click to expand... It is already a complex project (for me) i'm waiting for a bit of time to learn b4xpages. At the moment it is unconvenient to port it. Erel said: 2. What exactly are you doing in the "heavy task"? Click to expand... I'm downloading and storing big number of rows in a db (8000+) Erel said: 3. Why are you doing it in a service? It will not have any effect on the performance. Click to expand... I did a combination of the suggetions in this thread i opened some days ago: "Heavy work" and freezing - multithread? 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... www.b4x.com Upvote 0
Erel said: Everything will be simpler if you use B4XPages. Click to expand... It is already a complex project (for me) i'm waiting for a bit of time to learn b4xpages. At the moment it is unconvenient to port it. Erel said: 2. What exactly are you doing in the "heavy task"? Click to expand... I'm downloading and storing big number of rows in a db (8000+) Erel said: 3. Why are you doing it in a service? It will not have any effect on the performance. Click to expand... I did a combination of the suggetions in this thread i opened some days ago: "Heavy work" and freezing - multithread? 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... www.b4x.com
Erel B4X founder Staff member Licensed User Longtime User Mar 1, 2021 #4 No reason to use a service. Will not help. Mike1970 said: I did a combination of the suggetions in this thread i opened some days ago: Click to expand... The answer was given in the second post. You should use Wait For with a non query batch. Everything will happen in the background. Upvote 0
No reason to use a service. Will not help. Mike1970 said: I did a combination of the suggetions in this thread i opened some days ago: Click to expand... The answer was given in the second post. You should use Wait For with a non query batch. Everything will happen in the background.
M Mike1970 Well-Known Member Licensed User Longtime User Mar 1, 2021 #5 Erel said: No reason to use a service. Will not help. The answer was given in the second post. You should use Wait For with a non query batch. Everything will happen in the background. Click to expand... Yes infact i was trying to move the subs in a class instead of a service. Upvote 0
Erel said: No reason to use a service. Will not help. The answer was given in the second post. You should use Wait For with a non query batch. Everything will happen in the background. Click to expand... Yes infact i was trying to move the subs in a class instead of a service.