Solved

Time Delay in ASP

Posted on 2009-04-09
11
903 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
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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.

 
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
 
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
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…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

830 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