Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Time Delay in ASP

Posted on 2009-04-09
11
Medium Priority
?
909 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

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

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

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 response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

721 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