Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Wait() 4

Status
Not open for further replies.

DirtyB

Programmer
Mar 13, 2001
159
0
0
US
Is there a 'wait()' or 'pause()' function in ASP? I am sending out thousands of files, and i'm afraid i'll crash a server if I don't put a pause or wait in the loop somewhere. Does anyone know how this is done is asp?

Thanks
 
not that I'm aware of or can find...could you possibly use a for/next loop as a counter so that you send and email, run a counter that causes a pause then send the next email? Just a thought.
mark
 


dirtyb,

There is no wait or sleep function in ASP. There is a wscript.sleep function but that does not work in an ASP page. How is it that you are sending out thousands of files? Are people downloading files or do you have a script that just copies files from one server to a client?

You should let the net work throttle or adjust to your server's needs. Most networks these days are smart enough to handle that.

fengshui_1998
 
I have a script that is going to send out about 30,000 emails (not spam, I promise) at one time. I did this before and crashed our exchange server. So, I put a wait in the VB code and it worked fine, it gave exchange enough time to move the messages from folder to folder while sending. This time, they have to be sent with SMTP mail though, from an ASP page, I just wanted to put a small spacer in my code so I don't flood the server and it has enough time to do one email before several more come.

Any Ideas????

Thanks
 
i used this code in our file upload processing:

Code:
<%
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' This function is used to pause after file upload 
' to allow time for virus scan to work             
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Function pauseProcessing()
  ' Variables necessary to accomplish the task
  Dim TimerStart, TimerEnd, TimerNow, TimerWait
  ' How many seconds you want them to wait...
  TimerWait = 3
  ' Setup and start the timers
  TimerNow = Timer
  TimerStart = TimerNow
  TimerEnd = TimerStart + TimerWait 
  ' Keep it in a loop for the desired length of time
  Do While (TimerNow < TimerEnd)
    ' Determine the current and elapsed time
    TimerNow = Timer
    If (TimerNow < TimerStart) Then
      ' check for midnight.....
      TimerNow = TimerNow + 86400
    End If
  Loop 
  ' Time's up, resume original processing
End Function
%>
 
Great! Thanks, that's what i'm looking for. That is pretty similar to how I did it in VB. Just out of curiosity, what is the 86400?

Thanks
 
Yea, but the server is still just whizzing away on that loop pegging out the server resources, yes?

Is it really saving anything?

BTW, not arguing... just curious. While from the outside, it would appear as a sleep() function of some sort, your processor would disagree, I think.

Have you looked at the performance monitor on the server while this is running?
penny.gif
penny.gif
 
yeah, link9, you are correct, for the purpose we use it, to give the virus detection software time to check the file, i think it serves the purpose, but if the purpose is to pause all server processing, well, of course it's not doing that, cuz it's a process in itself.

good catch.

|-I
 
So the good news is that with ASP.NET, we'll have access to other languages to write our pages with that will give us real sleep() functions to use, if we so desire.

I have wanted for one several times, and just have never found anything in vbScript.

:)
penny.gif
penny.gif
 
dirtyb,

You can have your asp page fire off a vbscript file using the run command from using:

Set WSHShell = CreateObject(&quot;WScript.Shell&quot;)
wshell.run &quot;cmd /K yourscript&quot;


This woulod free up your ASP page and you would also get to use the wscript.sleep timer which would also not take up CPU resources.
 


dirtyb,

Sorry for the misprint:

Set wshell = CreateObject(&quot;WScript.Shell&quot;)
wshell.run &quot;cmd /K yourscript&quot;

fengshui_1998


 
Excellent, FengShui1998

**copies and pastes**

;-)
penny.gif
penny.gif
 
Today was the first time I needed a delay in ASP. I couldn't believe there was no sleep function. I finally had to use SQL server to get a 5 second delay. Hope this is helpful.

Set conn = Server.CreateObject(&quot;ADODB.Connection&quot;)
conn.open dtaDSN

conn.Execute(&quot;WAITFOR DELAY '000:00:05'&quot;)

conn.Close
set conn = Nothing
 
i think this is funny as as he**. i was looking for a sleep fucntion and came across this page. I was upset that there was no fucntion that would work. I was thinking microsoft would do something for this problem... then i found this on the microsoft support web site

Sub Sleep(tmpSeconds)
Dim dtmOne,dtmTwo
dtmOne = Now()
While DateDiff(&quot;s&quot;,dtmOne,dtmTwo) < tmpSeconds
dtmTwo = Now()
Wend
End Sub


i guess they dont care about processor cycles either.. With solutions like that now i know why windows crashes all the time!!

good enough for microcrap but not for me!
 
All,

There is no sleep function for ASP because these are web pages. In theory, the user should not be &quot;throttling&quot; the network. HTML is basically for informational purposes, query and response.

You should leave it up to the network protocols to determine how best it should send data to and from the client browser. I'm not endorsing this. This is just what it is.

fengshui_1998
 
one more working Wait()


Sub Wait(Seconds)
Message = &quot;&quot;
On Error Resume Next
CreateObject(&quot;wscript.shell&quot;).Popup Message, Seconds, &quot;&quot;, 64
End Sub
 
royred,

This is all futile. You will be assimulated. It doesn't make sense using a sleep timer on an ASP page. For example,
say you want to display the numbers from 1 thru 10 on the client at an interval of one second between numbers.

If the sleep timer was on the server, the CPU would execute the code every second. But that's not what controls the display or timer on the client. The browser controls that.

If the network was busy or the modem was slow and didn't update the client for 15 seconds, then you would have all these network packets backlogged and all the updates would come at once, NOT 1 second apart as you would think.

If W3 comes out with a client timer, then hooray!

p.s. royred, I don't think your code works on an ASP page.

Cheers,
fengshui_1998
 
FengShui1998,
I don't believe it's futile at all. If you take off the response.buffer, then it should filter it to the page somewhat accurately minus network problems...but the more important aspect is server-timing. First off, DirtyB (the originator of this forum) was wondering about timing the email sending on the server. While on a web page, it has nothing to do with the client side, therefore the timer would be of use. Second, I know I've run across pages where sending an email along with makeing a database entry and then redirecting to another page, the page would redirect too soon and the email would not be sent. Therefore, again, the timer would come in handy. Cheers! :) -Ovatvvon :-Q
 
Thanks Royred! Philosophy aside, you win the prize for simplicity. Your solution does not (1) hog the cpu, (2) require an external vbs script, or (3) require a database connection. I was concerned I might annoy my Server Support people with message boxes while they were logged on to the IIS server. However, I checked, and no message box actually appears! (I guess because IIS is a background process?) I couldn't get your syntax to work, but I just tested the code below, and it works great.

response.write &quot;Start... &quot; & time() & &quot;<br>&quot;
Const MESSAGE_TYPE_INFO = 64
Dim oWsh, sPopupText, sPopupTitle, nDelaySeconds
nDelaySeconds = 5
sPopupTitle = &quot;&quot;
sPopupText = &quot;&quot;
Set oWsh = Server.CreateObject(&quot;wscript.shell&quot;)
Call oWsh.popup(sPopupText, nDelaySeconds, sPopupTitle, MESSAGE_TYPE_INFO)
Set oWsh = Nothing
response.write &quot;Done... &quot; & time()
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top