VBScript Sleep

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.

Advertisements