Solved

Time Delay in ASP

Posted on 2009-04-09
11
901 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
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.

 
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

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 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/…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

912 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

20 Experts available now in Live!

Get 1:1 Help Now