S sally3599 Member Licensed User Longtime User Sep 9, 2012 #1 Is There any function to delay the app execution for a given number of seconds?
C cammel8 Member Licensed User Longtime User Sep 9, 2012 #2 sally3599 said: Is There any function to delay the app execution for a given number of seconds? Click to expand... you could set up a timer and when it fires execute your code then you could set the interval to whatever you wanted. Upvote 0
sally3599 said: Is There any function to delay the app execution for a given number of seconds? Click to expand... you could set up a timer and when it fires execute your code then you could set the interval to whatever you wanted.
Ricky D Well-Known Member Licensed User Longtime User Sep 9, 2012 #3 Using the timer seems the only way pseudo code Init Timer Do something Enable Timer . . . Timer Tick - continue doing stuff after the pause. It would be nice to be able to pause it at the line then after the pause continue. Using the timer breaks up the code. regards, Rick Upvote 0
Using the timer seems the only way pseudo code Init Timer Do something Enable Timer . . . Timer Tick - continue doing stuff after the pause. It would be nice to be able to pause it at the line then after the pause continue. Using the timer breaks up the code. regards, Rick
Erel B4X founder Staff member Licensed User Longtime User Sep 9, 2012 #4 Pausing the main thread will make your app unresponsive. Pausing for more than 5 seconds will crash your app with: "Application Not Responding" dialog. You can implement a "busy loop" method: Code: Copy Sub WaitFor(Milliseconds As Int) Dim s As Long s = DateTime.Now Do While DateTime.Now < s + Milliseconds Loop End Sub Upvote 0
Pausing the main thread will make your app unresponsive. Pausing for more than 5 seconds will crash your app with: "Application Not Responding" dialog. You can implement a "busy loop" method: Code: Copy Sub WaitFor(Milliseconds As Int) Dim s As Long s = DateTime.Now Do While DateTime.Now < s + Milliseconds Loop End Sub
Ricky D Well-Known Member Licensed User Longtime User Sep 9, 2012 #5 Thanks Erel. I've tested that and it works perfect. Code: Copy Dim starttime, endtime As Long Msgbox("Start waiting", "") starttime = DateTime.Now u.WaitFor(2000) '2 seconds endtime = DateTime.Now Msgbox(((endtime-starttime)/1000) & " seconds", "") There is a 2 second delay before the 2nd msgbox pops up and I can't click any of my other views on the screen. regards, Ricky Last edited: Sep 9, 2012 Upvote 0
Thanks Erel. I've tested that and it works perfect. Code: Copy Dim starttime, endtime As Long Msgbox("Start waiting", "") starttime = DateTime.Now u.WaitFor(2000) '2 seconds endtime = DateTime.Now Msgbox(((endtime-starttime)/1000) & " seconds", "") There is a 2 second delay before the 2nd msgbox pops up and I can't click any of my other views on the screen. regards, Ricky