Solved

Time Delay in ASP

Posted on 2009-04-09
11
900 Views
Last Modified: 2012-05-06
Hello guys,

I am having a problem with a code I am using to put a 10 seconds delay in an ASP code.

If you see the coding, works fine with the delay, but for some reason it kills the IIS. Is there any way to do a delay without overloading IIS?

Thanks.
Sub Delay(DelaySeconds)

SecCount = 0

Sec2 = 0

While SecCount < DelaySeconds + 1

Sec1 = Second(Time())

If Sec1 <> Sec2 Then

Sec2 = Second(Time())

SecCount = SecCount + 1

End If

Wend 

End Sub
 

Delay(10)

Open in new window

0
Comment
Question by:pvg1975
11 Comments
 
LVL 8

Expert Comment

by:the_crazed
ID: 24105726
do you have a handy SQL database connection?
you could use
dbConnection.Execute("WAITFOR DELAY '00:00:10'")

Open in new window

0
 

Author Comment

by:pvg1975
ID: 24105754
Yes, on a different server, but LAN wired with this one.

Will that overload the SQL Server?

Thanks!
0
 
LVL 4

Expert Comment

by:rentonc
ID: 24105762
I use a delay which uses the Javascript setTimeout() method and ASP to control the amount of time for triggering various pages or sections of code.

http://www.w3schools.com/htmldom/met_win_settimeout.asp

Other processes such as sleep from teh ASP site will kill the server unless you use a component.

0
 
LVL 8

Expert Comment

by:the_crazed
ID: 24105786
no, it won't overload the SQL sever; waitfor does not use CPU
0
 
LVL 8

Expert Comment

by:the_crazed
ID: 24105802
Bit of a hack I admit but there we are, that's life.
Might I ask, why do you need the wait? As rentonc is suggesting, perhaps you can rethink your design and do the wait clientside; that way you won't have to use a SQL process
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 23

Expert Comment

by:apresto
ID: 24105929
Here is my 5cents:
It discusses delay in ASP and using SQL Server as the_crazed suggested
http://classicasp.aspfaq.com/general/how-do-i-make-my-asp-page-pause-or-sleep.html
0
 
LVL 8

Expert Comment

by:the_crazed
ID: 24107491
good article; pretty much summarises what's been said here.
I notice that it does not say whether the author thinks that a call to SQL for a wait is a good thing or a bad thing...
personally, as I said, I think it should be avoided if possible, but may be a necessary evil if the need/reason is stong enough
0
 
LVL 8

Expert Comment

by:the_crazed
ID: 24107544
oh, except the handiest bit of the article, the link to WaitFor 1.0, does not work!
I guess ServerObjects have stopped doing that one. I wonder if there's another free one out there...
0
 

Author Comment

by:pvg1975
ID: 24110133
Hello guys,

Thanks for your replies.

The reason I need those 5 seconds, is because the ASP creates a record on a SQL Server. Then, an application developed in C# queries a QNX production server, returns a value, and place that value in the record created in the ASP file. Once that record is modified, the ASP file changes.

In other words the ASP Works like this:

INSERT INTO...
DO UNTIL PROCESSED=TRUE
     SELECT STATUS FROM QNX
     IF STATUS=10 THEN
         PROCESSED =TRUE
     END IF
     WAIT 5 SECONDS
LOOP
PRINT "PIPELINES STATUS:"

I need the loop until the QNX servers return the status to the .NET application, and this NET application writes the status on the record created by the ASP, then the ASP shows the result.
0
 
LVL 8

Accepted Solution

by:
the_crazed earned 500 total points
ID: 24115108
you could alter your design slightly:

Asp page page.asp creates the record on the sql server, and renders some Javascript to the client.
in this script, a timeout (as rentonc suggested) triggers a load of page.asp?check=true after 5 seconds.
when page.asp gets the param check=true, instead of doing its normal operation it simply checks the status of QNX. if the status is not 10, it simply renders the same javascript for the reload. if status is 10, it renders the Pipeline status as above.
you can render the client some useful message along with the script, like "Checking Pipeline" or something, more informative, its all good.
if you hate that solution, try and track down (or write) a wait component, or use my SQL hack.
0
 

Author Closing Comment

by:pvg1975
ID: 31568452
I will try to do something with JS.

Thanks!
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
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 video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

747 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

10 Experts available now in Live!

Get 1:1 Help Now