Solved

Sleeping in ASP

Posted on 2000-04-10
8
751 Views
Last Modified: 2008-03-10
Is there a way to pause or sleep during an ASP script.  Im writing a script in that I want the user to think that the computer is thinking, so I need some kind of sleep() function that will pause the script for about 10 seconds or so.

Thanks,
-Dan
0
Comment
Question by:dmaroff
8 Comments
 
LVL 1

Expert Comment

by:eladr
ID: 2700993
i think you can build a function
in javascript that do nothing and to set up setTimeout for this function.

elad
0
 
LVL 2

Expert Comment

by:bagi112599
ID: 2701141
say

<% response.buffer=true%>
before <html> tag
and
when you need a sleep
call...
<%

myMinutes =2
Response.Flush
goSleep (myMinutes) %>

<%
function goSleep(myMinutes)
dim  koef, timekiller
     koef=60*100000
for i=0 to myMinutes*koef
  timekiller=timekiller+1
  timekiller=timekiller-1
next

end function
%>
<br>
finished sleeping.

where koef is some value you have to adjust depending on your
server CPU speed.
But, depending on now much your server is busy, you will get not exact amount time of sleep.
hope it helps

bagi
0
 
LVL 4

Accepted Solution

by:
ruperts earned 30 total points
ID: 2701243
This will set you back exactly 10 seconds!

curr_time = now()
do while curr_time>dateadd("s",-10,now())
'do nothing
loop
0
 
LVL 15

Expert Comment

by:robbert
ID: 2701469
And, another one:

<%
Sub Sleep(intMilliseconds)
    dteEnd = DateAdd("s", intMilliSeconds/1000, Now)
    Do While dteEnd > Now
        'Sleep
    Loop
End Sub

Call Sleep(5000)
Response.Write "Something"
%>
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 

Author Comment

by:dmaroff
ID: 2701509
Good thinking it works great.  The only thing is that if I have a form that is posting to this page, it doesn't show this page until the page completely ends.  Any way around this?

Thanks,
-Dan
0
 
LVL 4

Expert Comment

by:ruperts
ID: 2701521
<% response.buffer=true%>
Pre wait code...

<% Response.Flush %>

waiting loop goes here!

<% Response.Flush %>
0
 
LVL 15

Expert Comment

by:robbert
ID: 2701623
ruperts' code is an endless loop...
I've been too late.
0
 
LVL 4

Expert Comment

by:ruperts
ID: 2701666
Q: why is it endless??

A: It's not.

Except:
It is only endless if time stands still! But then if time stood still you wouldn't know that you where actually waiting for it to finish as time would not be passing!

(The above doesn't apply if time goes backwards - that's a whole new theory!)
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now