Private Sub Button1_Click
pnlSnapshot.Color = xui.Color_Cyan
If pnl1.NumberOfViews > 0 Then pnl1.RemoveAllViews
If pnl2.NumberOfViews > 0 Then pnl2.RemoveAllViews
If pnl3.NumberOfViews > 0 Then pnl3.RemoveAllViews
If pnl4.NumberOfViews > 0 Then pnl4.RemoveAllViews
LoadImages
wait for LoadImages_Complete 'Added line
pnlSnapshot.SetBitmap(pnlImages.Snapshot)
End Sub
Private Sub LoadImages
Dim ListPanels As List = Array As B4XView(pnl1, pnl2, pnl3, pnl4)
For Each pnl As B4XView In ListPanels
MediaManager.SetMediaFromFile(pnl, File.DirAssets, "img.png", "image/*", CreateMap(MediaManager.REQUEST_BACKGROUND: xui.Color_Transparent, MediaManager.REQUEST_CALLBACK: Me))
Wait For (pnl) SMM_MediaReady (Success As Boolean, Media As SMMedia)
Next
CallSubDelayed(Me, "LoadImages_Complete") 'Added line
End Sub