Android Question [Solved] How I can perform this operation (wait for the sub terminate and start other sub)

asales

Expert
Licensed User
Longtime User
I have an app that upload several records to a server.
After it upload the data, it make some checks and I can get new data from the server.

Now I made this way (an example of my logical):
B4X:
Sub StartProcess
   SendData
End Sub

Sub SendData
   For i = 0 to data.size
       SendPut (...)
   Next
  
   DownloadData  ' <-- When the for terminate call the sub DownloadData
End Sub

Sub DownloadData
   SendRequest (...)   
End Sub

How I can make this way?:
B4X:
Sub StartProcess
   SendData
'   when the sub "SendData" terminate...
   DownloadData    ' <-- starts the sub "DownloadData"
End Sub
I tried, but the sub "DownloadData" starts before the sub "SendData" has completed.

Thanks in advance for any help.
 

DonManfred

Expert
Licensed User
Longtime User
Upvote 0

asales

Expert
Licensed User
Longtime User
Thanks! This is the code changed:
B4X:
Sub StartProcess
    Wait For(SendData) Complete (Result As Object)

    Wait For(DownloadData) Complete (Result As Object)
End Sub

Sub SendData As ResumableSub
    For i = 0 to data.size
        SendPut (...)
    Next

    Return Null
End Sub

Sub DownloadData As ResumableSub
    SendRequest (...)   

    Return Null
End Sub
 
Upvote 0
Top