F Fixx42 Member Licensed User Longtime User Apr 17, 2012 #1 Hello all, I have created a timer application that involves delays lasting up to about 10 seconds. When I run the process that involves these delays, I always run up against a "Activity XXXX (in application XXXX) is not responding" error message. Other than reducing the delays that this process incurs (I'm afraid that they're necessary to the app's functionality), does anyone know of a way for me to avoid this error? I would very much appreciate it! A little more on the app: When the user presses a button, the app plays a sound, waits a few seconds, plays another sound, waits 2 more seconds, plays another sound, and repeats this about 2 more times. Here's the code I'm using the create the delays: Code: Copy Sub Sleep(ms As Long) Dim now As Long now=DateTime.now Do Until (DateTime.now>now+ms) DoEvents Loop End Sub Thank you very much for the help!
Hello all, I have created a timer application that involves delays lasting up to about 10 seconds. When I run the process that involves these delays, I always run up against a "Activity XXXX (in application XXXX) is not responding" error message. Other than reducing the delays that this process incurs (I'm afraid that they're necessary to the app's functionality), does anyone know of a way for me to avoid this error? I would very much appreciate it! A little more on the app: When the user presses a button, the app plays a sound, waits a few seconds, plays another sound, waits 2 more seconds, plays another sound, and repeats this about 2 more times. Here's the code I'm using the create the delays: Code: Copy Sub Sleep(ms As Long) Dim now As Long now=DateTime.now Do Until (DateTime.now>now+ms) DoEvents Loop End Sub Thank you very much for the help!
NJDude Expert Licensed User Longtime User Apr 17, 2012 #2 You should read about TIMER, there are plenty of samples on the forums. The method you posted is not recommendable, you should use timers. Upvote 0
You should read about TIMER, there are plenty of samples on the forums. The method you posted is not recommendable, you should use timers.
William Hunter Active Member Licensed User Longtime User Apr 17, 2012 #3 Try this - the call is: Wait(1) - replace the 1 with whatever number of seconds you need. Code: Copy Sub Wait(Seconds As Int) 'Sleep for defined seconds Dim Ti As Long Ti = DateTime.Now + (Seconds * 1000) Do While DateTime.Now < Ti DoEvents Loop End Sub Upvote 0
Try this - the call is: Wait(1) - replace the 1 with whatever number of seconds you need. Code: Copy Sub Wait(Seconds As Int) 'Sleep for defined seconds Dim Ti As Long Ti = DateTime.Now + (Seconds * 1000) Do While DateTime.Now < Ti DoEvents Loop End Sub
F Fixx42 Member Licensed User Longtime User Apr 18, 2012 #4 NJDude said: You should read about TIMER, there are plenty of samples on the forums. The method you posted is not recommendable, you should use timers. Click to expand... Thank you very much NJDude, this worked perfectly and required only minor reworking of my existing code. My apologies for not doing a better search job before posting. Thank you for the input William, but I fear that the code you recommended would also lead to an "unresponsive" error (it is very similar to my existing code). Upvote 0
NJDude said: You should read about TIMER, there are plenty of samples on the forums. The method you posted is not recommendable, you should use timers. Click to expand... Thank you very much NJDude, this worked perfectly and required only minor reworking of my existing code. My apologies for not doing a better search job before posting. Thank you for the input William, but I fear that the code you recommended would also lead to an "unresponsive" error (it is very similar to my existing code).