Hi
I have seen what I think is instructive behaviour with this when doing things the way that
you are not supposed to! That is, when you are not using a sender filter.
In the code below, as you'd expect, imageview1 never gets a bitmap loaded. But what i found
surprising is that, more often than not, the image that is loaded into imageview2 is the one
that was supposed to end up in imageview1.
This suggests to me that the the job variable referenced after the wait for line in the
Sub DownloadFile can be different to the one declared in the same sub!
It really underlines the importance of the sender filter which would prevent this from
happening.
The other thing I noticed was that if you also had a Sub JobDone present then that would
capture whichever of the jobDone events that wasn't captured by Wait For.
Wait For will always have precedence over Sub jobdone but only for the raising of a single event.
If anything above is a misconception on my part I'd be very grateful to be put right!
I have seen what I think is instructive behaviour with this when doing things the way that
you are not supposed to! That is, when you are not using a sender filter.
In the code below, as you'd expect, imageview1 never gets a bitmap loaded. But what i found
surprising is that, more often than not, the image that is loaded into imageview2 is the one
that was supposed to end up in imageview1.
This suggests to me that the the job variable referenced after the wait for line in the
Sub DownloadFile can be different to the one declared in the same sub!
It really underlines the importance of the sender filter which would prevent this from
happening.
B4X:
Sub DownloadFile (webaddress As String, iv As ImageView)
Dim job As HttpJob
job.Initialize("", Me)
job.Download (webaddress)
wait for jobdone(job As HttpJob)
place = place + 1
Log(place)
iv.SetImage (job.GetBitmap)
End Sub
Sub Button1_Click
place = 0
ImageView1.SetImage(Null)
ImageView2.SetImage(Null)
ImageView3.SetImage(Null)
DownloadFile(strEiffelTower, ImageView1)
DownloadFile(strArcDeTriomphe, ImageView2)
End Sub
Sub jobdone(job As HttpJob)
place = place + 1
Log(place)
ImageView3.SetImage(job.GetBitmap )
End Sub
The other thing I noticed was that if you also had a Sub JobDone present then that would
capture whichever of the jobDone events that wasn't captured by Wait For.
Wait For will always have precedence over Sub jobdone but only for the raising of a single event.
If anything above is a misconception on my part I'd be very grateful to be put right!
Last edited: