Some members uses routines like:
It's purpose is to pause the app and refresh the GUI.
I tried to create a similar "function" to get the same behavior but avoiding the deprecated DoEvents.
This is my last attempt:
but it does not work as expected, because the GUI is not refreshed and, strangely, the 1 second pauses do not happen.
Is there a way to create a similar (same behavior) routine using resumable subs and avoiding to use DoEvents?
Thank you
B4X:
' call
Wait(1000)
' routine
Sub Wait(Duration As Long)
Dim ExitTime As Long = DateTime.Now + Duration
Do While DateTime.Now < ExitTime
DoEvents
Loop
End Sub
I tried to create a similar "function" to get the same behavior but avoiding the deprecated DoEvents.
This is my last attempt:
B4X:
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("layMain")
DateTime.TimeFormat = "mm:ss:SSS"
End Sub
Sub Activity_Resume
For i = 1 To 3
LogWithTime("I : " & i, Colors.Red)
Show
Next
End Sub
Sub Show
For j = 98 To 100
LogWithTime("J : " & j, Colors.Blue)
Label1.Text = j
Wait(1000) ' here I wish wait for one second, with GUI refresh
Next
End Sub
' ******************************************************
' *** These two routines should do what "I" need.
' *** Putting them in a simple library, you could have
' *** a Wait command which does what I mean.
Public Sub Wait(Duration As Long)
LogWithTime("Sub Wait", Colors.Black)
WaitHelper(Duration)
Wait For WaitHelper_Completed
End Sub
Private Sub WaitHelper(Duration As Long)
LogWithTime("Sub WaitHelper", Colors.Black)
Sleep(Duration)
CallSubDelayed(Me, "WaitHelper_Completed")
End Sub
' ******************************************************
Sub LogWithTime(Text As String, Color As Int)
LogColor(DateTime.Time(DateTime.Now), Colors.Green)
LogColor(TAB & Text, Color)
End Sub
but it does not work as expected, because the GUI is not refreshed and, strangely, the 1 second pauses do not happen.
Is there a way to create a similar (same behavior) routine using resumable subs and avoiding to use DoEvents?
Thank you
Last edited: