Android Question some httpjobs one after another

tufanv

Expert
Licensed User
Longtime User
Hello

I want to execute some httpjobs one ofther another but for example if i call the subs that executes the httpjob at the same time , it is not working obivously. ( arrays are being mixed ) . Also I dont want to start the next job's execution at previous one's jobdone for some reasons. So how can i call subs one after another when the executions aredone ? is it possible ?
 

tufanv

Expert
Licensed User
Longtime User
Everything is possible.

There is no problem with sending many HttpJobs at once.

If you want to send them one after another then you can create a list of HttpJobs, send the first one and then send the next one in JobDone. Until you complete sending all the jobs.
if i send all of them in one sub , it makes problem for example . these are the jobs for 1) getting server date 2 ) getting an array from the php

B4X:
If Job.JobName="tarihal" Then
    If Job.Success = True Then
                    Dim res As String
                    res = Job.GetString
                    Log("Response from server: " & res)
                    res=res.SubString2(10,res.Length-11)
             
                    lbldate.Text=res
                  

       
End If
End If

B4X:
If Job.JobName="sirketbilgileri" Then
    If Job.Success = True Then
                    Dim res As String
                    res = Job.GetString
                    Dim m As Map
                    Dim l As List
                    Dim parser As JSONParser
                    parser.Initialize(res)
                   
                    Log("Response from server: " & res)
                   
                    l=parser.NextObject
                    m=l.Get(0)
                    lblstable.Text=m.Get("stable")
                    lblresults.Text=m.Get("win")&"-"&m.Get("place")&"-"&m.Get("third")&"-"&m.Get("races")
                    lblmoney.text=NumberFormat2(m.Get("money"),0,0,0,True)
                    lblat.Text=m.Get("horses")
                    lbltarih.Text=m.Get("tarih")
                    loadingkapat
                   
                   
                   
                   
    End If
End If

these are the jobdones.
"tarihal" ( getdates) response is normally the date (something like now():2016/12/12 .... )
"sirketbilgileri" 's response is normally an array: Response from server: [{"win":"4","place":"3","third":"4"}]

if i send the 2 jobs together , i get an array error because for "sirketbilgileri" job, the response is mixed with the the "tarihal" ( get date ) and its response in the logs is the response of getting date , not the array . so it gives not an array error. Obviosuly i am doing something not right but what ?
 
Upvote 0

sorex

Expert
Licensed User
Longtime User
did you dim each job? it won't work right if you dim 1 job type and execute it several times.
 
Upvote 0

inakigarm

Well-Known Member
Licensed User
Longtime User
You'd have to create a list with the jobs, send the first job (list.get(0)) and in Jobdone Sub, remove the first item of list (list.removeat(0)) and send the second job (now in list.get(0)) and so on. See this post
 
Upvote 0
Top