Android Question [solved] Wait for throws doesn't wait

JDS

Active Member
Licensed User
I've got a http download which doesn't respect the "wait for". Am I missing something?

in my main I've the following

B4X:
Log("in MAIN - before callsub")
CallSub(Starter,"GetNewRoute")
Log("in MAIN - after callsub")
In the Starter:

B4X:
Sub GetNewRoute
    Dim j As HttpJob
    Dim requestSoapXML As String
    Dim sChar As String
   
   
    sChar = "&"
    requestSoapXML = "http://192.168.100.124/status/com.wso/GetRoute13/JSON?iPDA="&"1203"&sChar&"sWachtwoord="&"QWIvL05VUTVHTEorNmIxektaWWNGS"&sChar&"sExtra="&""
    j.Initialize("",Me)
    j.Download(requestSoapXML)
    wait for (j) jobdone(j As HttpJob)
    If j.Success Then
        Log ("succes download")
        j.Release
    Else
        Log ("failed download")
        j.Release
    End If
End Sub
The log is
"
in MAIN - before callsub
in MAIN - after callsub
succes download
"
 

DonManfred

Expert
Licensed User

DonManfred

Expert
Licensed User
https://www.b4x.com/android/forum/threads/b4x-resumable-subs-that-return-values-resumablesub.82670/
Logger verbunden mit: 988ad036525346515630
--------- beginning of crash
--------- beginning of main
--------- beginning of system
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
in MAIN - before callsub
*** Service (httputils2service) Create ***
** Service (httputils2service) Start **
succes download
in MAIN - after callsub
** Activity (main) Pause, UserClosed = false **
B4X:
Sub test
    Log("in MAIN - before callsub")
    
    Wait For(CallSub(Starter,"GetNewRoute")) Complete (Result As String)
    Log("in MAIN - after callsub")
End Sub
B4X:
Sub GetNewRoute As ResumableSub
    Dim j As HttpJob
    Dim requestSoapXML As String
    Dim sChar As String
    Dim result As String = ""
    
    sChar = "&"
    requestSoapXML = "https://www.duckduckgo.com"
    j.Initialize("",Me)
    j.Download(requestSoapXML)
    wait for (j) jobdone(j As HttpJob)
    If j.Success Then
        result = j.GetString
        Log ("succes download")
        j.Release
    Else
        Log ("failed download")
        j.Release
    End If
    Return result
End Sub
 

Attachments

DonManfred

Expert
Licensed User
This works
make sure to check the tutorial i linked otherwise you´ll get trapped again next time....

PS: You should click on the LIKE button on the helpful post to give back some honor
 
Last edited:

BillMeyer

Well-Known Member
Licensed User
PS: You should click on the LIKE button on the helpful post to give back some honor
I agree. This always motivates the responder to give more advice and solutions next time.
 

OliverA

Expert
Licensed User
Top