How Keeping delay / wait for job sucess in For loop to process Http jobs

sasidhar

Active Member
Licensed User
Longtime User
Dear all,

I have a problem during data sending to server. for loop used for send data to sever. before getting previous job sucess another one getting executed, say out of 20 records only 10 records being sent.

if i keep message box and check between loop all data posted to server. some delay is required or how to wait till get job sucess in loop.

please find the code below and give soln.

<------

For i=0 To tCursor2.RowCount-1
tCursor2.Position = i
trstr=(tCursor2.GetString("Trans_str")) ' Note:Field names Case sensitive
Dim htjob2 As HttpJob
htjob2.Initialize("Job2", Me)
htjob2.PostString(trstr,"")
esq1="delete from Transaction_Table where Trans_str=" & """" & trstr & """" &""
sql1.ExecNonQuery(esq1)
For j=0 To 10000
Next
'ToastMessageShow("Data Posting InProgress..Don't Exit from Application " & i & " of " & tCursor2.RowCount,True)
Next

..........>

Thanks
Sasidhar
 

KMatle

Expert
Licensed User
Longtime User
Use a counter (j=j+1) for every job sent and subtrakt 1 from it for every job done.

Deaactivate all Buttons & other disturbing functions like timers. When all jobs are done, activate them again.

When the user presses the "Back Key" you can check this, too in combination with the counter:

B4X:
Sub Activity_KeyPress(KeyCode As Int) As Boolean

    If KeyCode = KeyCodes.KEYCODE_BACK Then
        If j > o  then 'which means there is still at least one job not finished
            ToastMessageShow("Database is being updated. Please wait...", True)
            Return True
        Else
            Activity.Finish
        End If
    Else
         Return True
    End If
   
End Sub
 
Top