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
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.
This document is intended to add a little understanding as to how Resumable Subs actually work under the bonnet and is intended as a complement to how they are used as Erel explains in his tutorials. Note that the following applies equally to B4A, B4I and B4J. At the heart of the main thread of...
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.
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.
Thanks @agraham and @Erel I follow your tutorial and everything working fine now.
I initialize classs inside the button with a wait for and working fine.