Private Sub Button1_Click
Private reqs As List
reqs.Initialize
Log("Creating object 1")
Private mp1 As Map = CreateMap("item":1,"name":"req1","object":DoReq1)
reqs.Add(mp1)
Log("Creating object 2")
Private mp2 As Map = CreateMap("item":2,"name":"req2","object":DoReq2)
reqs.Add(mp2)
Log("Creating object 3")
Private mp3 As Map = CreateMap("item":3,"name":"req3","object":DoReq3)
reqs.Add(mp3)
Log("======Starting=====")
wait for (callwithhalt(reqs)) complete (retn As Boolean)
Log($"=====Finishing===== success is ${retn}"$)
End Sub
private Sub callwithhalt(reqs As List) As ResumableSub
Private i As Int
For i = 0 To reqs.Size -1
Private mp As Map = reqs.Get(i)
Log($"Calling ${mp.Get("name")}"$)
wait for (mp.Get("object")) done(result As Map)
Log($"Done ${mp.Get("name")}"$)
If Not(result.getdefault("success",False)) Then
Return False
End If
Next
Return True
End Sub
private Sub DoReq1
Log("starting Req1")
Dim result As Map = CreateMap()
Dim j As HttpJob
j.Initialize("1", Me)
j.Download("https://www.google.com")
Wait For (j) JobDone(j As HttpJob)
Log("------DoReq1 =" & j.Success)
result.put("success", j.Success)
j.Release
CallSub2(Me,"done", result)
End Sub
private Sub DoReq2
Log("starting Req2")
Dim result As Map = CreateMap()
Dim j As HttpJob
j.Initialize("2", Me)
j.Download("https://www.google.com")
Wait For (j) JobDone(j As HttpJob)
Log("------DoReq2 =" & j.Success)
result.put("success", j.Success)
j.Release
CallSub2(Me,"done", result)
End Sub
private Sub DoReq3
Log("starting Req3")
Dim result As Map = CreateMap()
Dim j As HttpJob
j.Initialize("3", Me)
j.Download("https://www.google.com")
Wait For (j) JobDone(j As HttpJob)
Log("------DoReq3 =" & j.Success)
result.put("success", j.Success)
j.Release
CallSub2(Me,"done", result)
End Sub