I’ve just had a requirement for a sleep command in ASP, apparently there isn’t one (not that I can find). There is a Wscript.Sleep for command line VBS’s but nothing in ASP.
So, I’ve written a really quick simple one that some might find useful –
Sub Sleep(intSecs) Dim dtStart, boolDone dtStart = now() boolDone = False While Not boolDone If DateDiff("s",dtStart,now()) >= cint(intSecs) Then boolDone = True End If Wend End Sub
Update: As noted in the comments, this really *shouldn’t* be used as it pins your CPU. If you must use it, please be aware of what it’s doing.
September 5, 2006 at 1:21 am
Awesome. I can now empbed a sleep function inside my wise packages. Thanks a million!
June 28, 2008 at 3:51 pm
your pinning your cpu this way, not good. change. please.
June 28, 2008 at 7:39 pm
Thanks for your comment DJ, to be honest I’ve not used this one (or had a need for it) in ages. Do you have a way that doesn’t pin the CPU? I’ll have a think.. (I don’t really do much classic ASP anymore).
August 29, 2008 at 12:35 pm
Thanks very much works very well
August 4, 2009 at 11:07 am
Yeah, I’m sorry, but dj is right. While this technique works in theory, it’s a very bad idea in practice.
Although it works, it’ll force your CPU (or core) usage up to 99 or 100%, ironically when the code is meant to be doing *nothing*! Very strongly NOT recommended.
It’s a PITA that classic ASP doesn’t appear to have a proper Sleep command.