Android Question call multi httpjob

nadhiras

Member
Licensed User
if I have 3 HttpJob requests, how do I do this, does it separate each JOB like this:

B4X:
Wait For (CallSub(Me, "job1")) Complete (Result As Boolean)
    If Result Then
     .....
    End If

Wait For (CallSub(Me, "job2")) Complete (Result As Boolean)
    If Result Then
     .....
    End If

Wait For (CallSub(Me, "job3")) Complete (Result As Boolean)
    If Result Then
      ......
    End If
or like this:

B4X:
Wait For (CallSub(Me, "job1")) Complete (Result As Boolean)
    If Result Then
       Wait For (CallSub(Me, "job2")) Complete (Result As Boolean)
         If Result Then
            Wait For (CallSub(Me, "job3")) Complete (Result As Boolean)
               If Result Then
                 ......
               End If
        End If
    End If
 

nadhiras

Member
Licensed User
yes must in order don...

in the 2nd job there is a SQL command and I use SQL.AddNonQueryToBatch.
whether the third JOB is better placed in the sub SQL_NonQueryComplete?
so it becomes like this :

B4X:
Wait For (CallSub(Me, "job1")) Complete (Result As Boolean)
    If Result Then
       Wait For (CallSub(Me, "job2")) Complete (Result As Boolean)
         If Result Then
                     ....................
                    SQL.AddNonQueryToBatch(................))
                   SQL.ExecNonQueryBatch("SQL")
        End If
    End If

Sub SQL_NonQueryComplete (Success As Boolean)
    If Success Then
         Wait For (CallSub(Me, "job3")) Complete (Result As Boolean)
               If Result Then
                 ......
               End If
    End If
End Sub
or remain as before ?
 

OliverA

Expert
Licensed User
o you want them to call in order? Use the seconds version.
Unless I'm misunderstanding something about Wait For, both versions (shown in the first post of this thread) execute in order. The difference is that in the first version, the following Wait For's are executed without regards to what the previous Wait For's return value for Result is (True or False, the other Wait For's execute), whereas in the second example, each of the following Wait For's are only executed if Result is True.
 
Top