Solved

Time Delay in ASP

Posted on 2009-04-09
11
905 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
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 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

Technology Partners: 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!

Question has a verified solution.

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

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 informatio…
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…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

751 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