Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Sun May 20, 2018 11:54 pm
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Pause/wait for x number a milliseconds in a program
PostPosted: Tue Apr 02, 2013 1:58 am 
Offline

Joined: Sat Mar 30, 2013 6:02 am
Posts: 4
Hi,
I’m looking for a way to pause/wait for 500 milliseconds in a program like:

Some code

Wait 500 milliseconds

Rest of the code

What would be the best way to do it?

Thanks,
Nicolas


Top
 Profile  
Reply with quote  
 Post subject: Re: Pause/wait for x number a milliseconds in a program
PostPosted: Tue Apr 02, 2013 2:24 am 
Offline

Joined: Fri Jan 06, 2006 3:21 pm
Posts: 12388
Location: Portland, OR USA
2 possibilities:

1) Put the code into a thread.
Some code
me.sleep(500)
Rest of the code

2) Put "Rest of the code" into the Action event of a timer.
Some code
Start the timer


Top
 Profile  
Reply with quote  
 Post subject: Re: Pause/wait for x number a milliseconds in a program
PostPosted: Tue Apr 02, 2013 10:31 am 
Offline
User avatar

Joined: Mon Feb 05, 2007 5:21 pm
Posts: 600
Location: New York, NY
What, if anything, do you want the rest of your app to do during that pause? Just lock up, or allow user interaction?

I guess what I'm asking is, why do you want the pause in the first place? That answer will determine the best way to do it.

Aside from Tim's suggestions, you could also do this, but it would lock up your app during the pause:
dim startTime as double = microseconds
while ( microseconds - startTime ) < 500000
App.YieldToNextThread // Or something
wend

_________________
Kem Tekinay
MacTechnologies Consulting
http://www.mactechnologies.com/

Need to develop, test, and refine regular expressions? Try RegExRX.


Top
 Profile  
Reply with quote  
 Post subject: Re: Pause/wait for x number a milliseconds in a program
PostPosted: Tue Apr 02, 2013 11:37 am 
Offline

Joined: Sat Mar 30, 2013 6:02 am
Posts: 4
I would like to pause the program because I need to interact with the Mac clipboard. I need to make sure that the past (cmd + c) in the clipboard is first finished before I alter the clipboard. So I don't know if it is the best way of doing it, but now it's working.

The related post:
viewtopic.php?f=10&t=47473

I actually use now:
app.SleepCurrentThread(500)


Top
 Profile  
Reply with quote  
 Post subject: Re: Pause/wait for x number a milliseconds in a program
PostPosted: Tue Apr 02, 2013 11:54 am 
Offline
User avatar

Joined: Mon Feb 05, 2007 5:21 pm
Posts: 600
Location: New York, NY
Unless you're calling that code from a thread other than the main thread, it doesn't actually do anything.

_________________
Kem Tekinay
MacTechnologies Consulting
http://www.mactechnologies.com/

Need to develop, test, and refine regular expressions? Try RegExRX.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 5 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group