I have some code:
in which the delay loop is working OK because I can see the number sequence written to the log after each 2 second delay, but each of the rectangles is not made visible in sequence, with all showing together after all delay loops have completed.
How can I make the UI update before each delay loop is called so the rectangles are displayed in sequence?
B4X:
Sub btnFoulLights_Action ' Enable foul light testing
If btnFoulLights.Selected Then
Dim joRect As JavaObject = Rin1TeamFoulsRect
joRect.RunMethod("setVisible", Array(True))
Log("1")
Wait(2000)
Dim joRect As JavaObject = Rin2TeamFoulsRect
joRect.RunMethod("setVisible", Array(True))
Log("2")
Wait(2000)
Dim joRect As JavaObject = Rin3TeamFoulsRect
joRect.RunMethod("setVisible", Array(True))
Log("3")
Wait(2000)
Dim joRect As JavaObject = Rin4TeamFoulsRect
joRect.RunMethod("setVisible", Array(True))
Log("4")
Wait(2000)
Dim joRect As JavaObject = Rin5TeamFoulsRect
joRect.RunMethod("setVisible", Array(True))
Log("5")
Wait(2000)
Dim joRect As JavaObject = Vis1TeamFoulsRect
joRect.RunMethod("setVisible", Array(True))
Log("6")
Wait(2000)
Dim joRect As JavaObject = Vis2TeamFoulsRect
joRect.RunMethod("setVisible", Array(True))
Log("7")
Wait(2000)
Dim joRect As JavaObject = Vis3TeamFoulsRect
joRect.RunMethod("setVisible", Array(True))
Log("8")
Wait(2000)
Dim joRect As JavaObject = Vis4TeamFoulsRect
joRect.RunMethod("setVisible", Array(True))
Log("9")
Wait(2000)
Dim joRect As JavaObject = Vis5TeamFoulsRect
joRect.RunMethod("setVisible", Array(True))
Log("10")
Else
Dim joRect As JavaObject = Rin1TeamFoulsRect
joRect.RunMethod("setVisible", Array(False))
Dim joRect As JavaObject = Rin2TeamFoulsRect
joRect.RunMethod("setVisible", Array(False))
Dim joRect As JavaObject = Rin3TeamFoulsRect
joRect.RunMethod("setVisible", Array(False))
Dim joRect As JavaObject = Rin4TeamFoulsRect
joRect.RunMethod("setVisible", Array(False))
Dim joRect As JavaObject = Rin5TeamFoulsRect
joRect.RunMethod("setVisible", Array(False))
Dim joRect As JavaObject = Vis1TeamFoulsRect
joRect.RunMethod("setVisible", Array(False))
Dim joRect As JavaObject = Vis2TeamFoulsRect
joRect.RunMethod("setVisible", Array(False))
Dim joRect As JavaObject = Vis3TeamFoulsRect
joRect.RunMethod("setVisible", Array(False))
Dim joRect As JavaObject = Vis4TeamFoulsRect
joRect.RunMethod("setVisible", Array(False))
Dim joRect As JavaObject = Vis5TeamFoulsRect
joRect.RunMethod("setVisible", Array(False))
End If
End Sub
Sub Wait(ms As Int)
Dim nn As Long = DateTime.Now + ms
Do While DateTime.Now < nn
Loop
End Sub
in which the delay loop is working OK because I can see the number sequence written to the log after each 2 second delay, but each of the rectangles is not made visible in sequence, with all showing together after all delay loops have completed.
How can I make the UI update before each delay loop is called so the rectangles are displayed in sequence?