Solved

Sleeping in ASP

Posted on 2000-04-10
8
757 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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
 

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Get hold of longitude and latitude in iframe string 11 51
Asp in server side with Mssql Server 7 4 33
Html value of radio 14 43
Ajax on ASP 2 32
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
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/…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

685 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