Android Question Sleep vs Doevents - waiting actions like 'closedrawer'

scsjc

Well-Known Member
Licensed User
Longtime User
Hello
I'm use a doevents to wait actions (like closedrawer, i atach a sample). I try use with sleep, and the visual efect is not nice.

B4X:
Sub NavDrawer_NavigationItemSelected (MenuItem As ACMenuItem, DrawerGravity As Int)
   NavDrawer.CloseDrawer
   WaitFor(400)
    Select Case MenuItem.Id
       Case 1:
           ...
    End Select
end sub

Sub WaitFor(Milliseconds As Double)
   If Milliseconds=0 Then
       DoEvents
   Else
       Dim s As Long
       s = DateTime.Now
       Do While DateTime.Now < s + Milliseconds
           DoEvents
       Loop
   End If
End Sub
 

Emme Developer

Well-Known Member
Licensed User
Longtime User
Hello
I'm use a doevents to wait actions (like closedrawer, i atach a sample). I try use with sleep, and the visual efect is not nice.

B4X:
Sub NavDrawer_NavigationItemSelected (MenuItem As ACMenuItem, DrawerGravity As Int)
   NavDrawer.CloseDrawer
   WaitFor(400)
    Select Case MenuItem.Id
       Case 1:
           ...
    End Select
end sub

Sub WaitFor(Milliseconds As Double)
   If Milliseconds=0 Then
       DoEvents
   Else
       Dim s As Long
       s = DateTime.Now
       Do While DateTime.Now < s + Milliseconds
           DoEvents
       Loop
   End If
End Sub
I don't understand.. have you tried to use sleep(400)?
 
Upvote 0
Top