Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Thread Sleep in Classic ASP?

I'm doing some revision on an old app that is written in classic ASP/VbScript.

It has a feature to send out an e-mail to the members of the application, but because the member list is quite large, the server rejects new e-mails after the first hundred or so are sent.

I've written some code to make it send out e-mails in burst of 20, but this still doesn't work. I think that perhaps making it sleep for a second between burst might work properly.

However, I can't seem to find a Thread.Sleep type method in VbScript.

Is there one?

like image 313
FlySwat Avatar asked Dec 19 '08 01:12

FlySwat


2 Answers

This routine waits any amount of time, and doesn't use CPU:

Function asp_Wait(nMilliseconds)
  Dim oShell
  '' VBS: Set oShell= Wscript.CreateObject("WScript.Shell")
  '' ASP:
  Set oShell= Server.CreateObject("WScript.Shell")
  Call oShell.run("ping 1.1.1.1 -n 1 -w " & nMilliseconds,1,TRUE) 
  '' Option TRUE: Wait until ping is complete
  '' 1000 milli-second wait is 1 second
End Function
like image 112
Bob Monahon Avatar answered Sep 21 '22 20:09

Bob Monahon


there is also a good hta hack that should work. Look for the A Synthetic Sleep Function here: http://www.mvps.org/scripting/rube/index.htm

like image 31
mrTomahawk Avatar answered Sep 23 '22 20:09

mrTomahawk