Android Question How to run multiple HttpJob for common tables

Richard Goh

Active Member
Licensed User
Longtime User
Hi,

I have few common tables having a same table structure (e.g, f1, f2) but different contents. So I created a function to perform the same download process for those tables by passing in the table name for the job to process (as below). I got no problem by running the job after one job is finished. But the XML parser (jobxxx_EndElement) will confused when I run multiple jobs simultaneously.
How can I overcome this problem on running the jobs simultaneously without the problem.
Any advice on this? Thanks in advance.

B4X:
Sub StartDownload(tablename As String)
    If xfs.CheckConnection Then               
        template = File.ReadString(File.DirAssets, tablename & ".xml")
        parser.Initialize           
       
        Dim job As HttpJob
        job.Initialize(tablename, Me)       
        job.PostString(URL, BuildRequest)
        job.GetRequest.SetContentType("text/xml; charset=utf-8")
        job.GetRequest.SetHeader("SOAPAction", """http://tempuri.org/" & tablename & """")       
    Else
        Activity.Finish
    End If   
End Sub


StartDownload("Table1")
StartDownload("Table2")
StartDownload("Table3")
StartDownload("Table4")
 

DonManfred

Expert
Licensed User
Longtime User
B4X:
Sub StartDownload(tablename As String)
    If xfs.CheckConnection Then              
        template = File.ReadString(File.DirAssets, tablename & ".xml")
        parser.Initialize          
      
        Dim job As HttpJob
        job.Initialize(tablename, Me)
        job.Tag = tablename
You can check the value of job.tag in the sub JobDone and depending on the value of the tag you can handle the processing of the table...
 
Upvote 0

Richard Goh

Active Member
Licensed User
Longtime User
Hi, I managed to solve the problem by using class to handle the xml parsing.
Thanks for the suggestion.
 
Upvote 0
Top