B4J Question Resumable subs: wait for multiple events ?

EnriqueGonzalez

Well-Known Member
Licensed User
Longtime User
Is it possible to "wait for" more than one event ?

Yes, just dont forget to put the Sender name.

Like this example:

B4X:
'Good example. Use.

Sub DownloadImage(Link AsString, iv AsImageView)
Dim job AsHttpJob
job.Initialize("", Me) 'note that the name parameter is no longer needed.
 job.Download(Link)
 Wait For (job) JobDone(job AsHttpJob)
If job.Success Then
iv.SetImage (job.GetBitmap) 'replace with iv.Bitmap = job.GetBitmap in B4A / B4i
End If
job.Release
End Sub

Or should these multiple events be wrapped into a single event and wait for this event ?

It is a possibility, i believe that the more you use wait for, it will be more difficult for you to control your program.
 
Last edited:
Upvote 0

wl

Well-Known Member
Licensed User
Longtime User
S
Yes, just dont forget to put the Sender name.

Like this example:

B4X:
'Good example. Use.

Sub DownloadImage(Link AsString, iv AsImageView)
Dim job AsHttpJob
job.Initialize("", Me) 'note that the name parameter is no longer needed. job.Download(Link) WaitFor (job) JobDone(job AsHttpJob)
If job.Success Then
iv.SetImage (job.GetBitmap) 'replace with iv.Bitmap = job.GetBitmap in B4A / B4i
End If
job.Release
End Sub



It is a possibility, i believe that the more you use wait for, it will be more difficult for you to control your program.

Sorry, I don't understand the example. Where is the "wait for" in this example ?

Thanks
 
Upvote 0

EnriqueGonzalez

Well-Known Member
Licensed User
Longtime User
sorry i corrected the Code quotes,

I copy pasted from the tutorial example but it pasted messed up.

B4X:
Wait For (job) JobDone(job AsHttpJob)
This code is called several times, so as far as you use the (job) {sender} you can use it more than once.
 
  • Like
Reactions: wl
Upvote 0
Top