Android Question [Solved] How to fix multiple Wait For

asales

Expert
Licensed User
Longtime User
Based in this post:
https://www.b4x.com/android/forum/t...-native-ads-advanced.88100/page-2#post-567437
I created several "Wait For" to load a different native ad.
B4X:
Wait for (LoadNativeAd("ca-app-pub-3940256099942544/2247696110")) Complete (Result As Panel)
If Result <> Null Then
    Activity.AddView(Result, 0, 0, 100%x, 132dip)
End If

Wait for (LoadNativeAd("ca-app-pub-3940256099942544/2793859312")) Complete (Result As Panel)
If Result <> Null Then
    Activity.AddView(Result, 0, 30%y, 100%x, 132dip)
End If
    
Wait for (LoadNativeAd("ca-app-pub-3940256099942544/2247696110")) Complete (Result As Panel)
If Result <> Null Then
    Activity.AddView(Result, 0, 60%y, 100%x, 150dip)
End If

But If the second "Wait For" don't get the Ad, the third Wait For is not raised too.

I saw this line from Erel and the video tutorial about Resumable Sub:
Wait For can distinguish between events based on the event sender.
This is done with an optional parameter:
Wait For (<sender>) <event signature>


But I don't know how to implement this in my code?

Thanks in advance for any tips.
 

OliverA

Expert
Licensed User
Longtime User
I don't think this applies here. As soon as you use Wait for, the processing continues from the location that called the code that contained the Wait for statements. So if the second Wait for is never raised, then the third Wait for is never called. @Erel's comment pertains to a case where multiple Wait for(s) are called in succession (without completing) or are nested in each other. In your case, only one Wait for at a time is executed and the next Wait for is only executed if the previous one is raised.
 
Upvote 0
Top