Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Visual Basic
Expertise: Beginner
Dec 23, 1997

Wait for 1 second

Question:
I have a place in my Active Server Page script (VBScript) where I'd like to wait for 1 second before performing an action. What can one do to cause a script to pause for 1 second (without wasting CPU in some huge "For..." loop)?

Answer:
If all you want to do is wait, I've got a really simple answer. Call the Sleep API.

   Private Declare Sub Sleep Lib "kernel32" Alias "Sleep" (ByVal dwMilliseconds As Long)

   Call Sleep(1000)
This will put your application into a hibernation-like mode, as it will not do anything (respond to the user, paint itself, fire events, etc.) until the call returns. This call is designed to conserve CPU cycles during periods when an application doesn't need to be active.
DevX Pro
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date