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)?
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.