Solved

Sleeping in ASP

Posted on 2000-04-10
8
754 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
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/…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

920 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

13 Experts available now in Live!

Get 1:1 Help Now