Android Question [SOLVED] Wait For not waiting inside class.

makis_best

Well-Known Member
Licensed User
Longtime User
Hi.

I have a class and I use it for reading a JSON.
The problem is that the wait for not waiting at all.
My link is correct parameter's are correct but keep not waiting.
When code reach Wait For my code exit.
Any idea?

B4X:
        Dim Link As String = "Http://localhost:8081"
        Dim j1 As HttpJob
        j1.Initialize("", Me)
        Dim Body As Map = CreateMap( "service" : "getTableFields", "ID" : clientID1, "app" : app, "obj" : obj1, "table" : t1)
        Parameters = Body.As(JSON).ToString
'        Log("GetTableFields Parameters: " & Parameters)
               
        j1.PatchString(Link, Parameters)
        Wait For (j1) JobDone(j1 As HttpJob)  <---- Not waiting.
        If j1.Success Then
 
Last edited:

agraham

Expert
Licensed User
Longtime User
That's expected and is how Wait For works. Wait For immediately exits the Sub in which it is called and then the Sub is re-entered at that point when the JobDone event occurs.
 
Upvote 0

Sagenut

Expert
Licensed User
Longtime User
Not sure if I understood it correctly, probably his problem is that the code flow return back to Main before the Class finish the jobs.
This could help, in the case.
 

Attachments

  • Wait For Class.zip
    9.7 KB · Views: 53
Upvote 0

makis_best

Well-Known Member
Licensed User
Longtime User
Yes, exactly when the class Initialize inside B4XPage the code proceed and then get back to B4XPage without finish.
I Initialize class inside a button of a B4XPage.
 
Upvote 0
Top