?
Solved

pause asp script

Posted on 2004-04-07
15
Medium Priority
?
2,126 Views
Last Modified: 2012-06-27
Im working on a server push concept for a project im working on.

However i need to pause the script for a certain amount of seconds, I can do this with a do : loop but this consumes 100% cpu.

Does anyone have a method that will not use all the CPU?
0
Comment
Question by:yobyfed
[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
  • 3
  • 3
  • 3
  • +3
15 Comments
 
LVL 31

Expert Comment

by:alorentz
ID: 10774941
Don't think you can do it....
0
 
LVL 21

Expert Comment

by:ap_sajith
ID: 10774957
Use the function to introduce delay in your scripts..

<%
' ** SUBROUTINE TO INTRODUCE DELAY **
Sub Delay(DelaySeconds)
      ' Counter initialized to 0
      SecCount = 0
      ' variable for comparison initialized to 0
      Sec2 = 0      
      'Loop
      While SecCount < DelaySeconds + 1
            'Each time the loop is executed, sec1 variable holds the value of the curent second
            Sec1 = Second(Time())
            'Each time the loop is executed,the check is performed
            If Sec1 <> Sec2 Then
                  Sec2 = Second(Time())
                  'Both these values are incremented each second only.
                  SecCount = SecCount + 1
            End If
      Wend
End Sub

' ** Introduce delay of 5 seconds **
CALL Delay(5)

%>

Hope this helps..

Cheers!!
0
 
LVL 31

Expert Comment

by:alorentz
ID: 10775418
Isn't that the loop he already discussed....100% CPU usage?
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 35

Expert Comment

by:YZlat
ID: 10775934
0
 
LVL 35

Expert Comment

by:YZlat
ID: 10775946
or javascript SetTimeout function
0
 
LVL 35

Expert Comment

by:YZlat
ID: 10775973
<SCRIPT LANGUAGE="JavaScript">
function sleep()
{
  setTimeout("sleep()", 500);
}
</SCRIPT>
0
 
LVL 4

Accepted Solution

by:
anderson22 earned 500 total points
ID: 10776296
use sleep from asp (server side).  You will need to use Windows Scripting which means that your virtual directory will have to support Execute priviliges.

Here is the API:
http://msdn.microsoft.com/archive/default.asp?url=/archive/en-us/wsh/htm/wsMthSleep.asp

Using Windows Script from ASP:
http://www.experts-exchange.com/Web/Web_Languages/ASP/Q_20172579.html?query=asp+WScript&searchType=topic


-rca
0
 
LVL 11

Expert Comment

by:mouatts
ID: 10777475
This is unlikely to have the effect that you want.
Even with buffering turned off the data from you page is not sent immediatly until enough data is available to form a full HTTP message (I think this is 64K) or the page execution completes. Consequently by introducing a delay in the page execution it will not look like server push unless each block is certain to exceed this value.
It also will increase the load on your server and reduce the maximum number of concurrent users supported because the port will be open that much longer.
I'd suggest that a better approach may be to send the whole page at once and use javascript to progressively display it.

HTH
Steve
0
 

Author Comment

by:yobyfed
ID: 10782097
ap_sajith: The loop will consume all resources

YZlat: ASP does not support the setTimeout function, as ASP is terminated once the script ends.

anderson22: Do you know if using the wsh.sleep function will pause only the current document, or the whole application?, for the single user, or all users connected?
0
 

Author Comment

by:yobyfed
ID: 10782119
mouatts:  The reason for this approach is for a web MSN clone im working on, I want to try and make it seemless server push rather than ugly old client pull.

I am able to successfully replicate this using ap_sajith's method, However it takes up too much resources.
0
 
LVL 11

Expert Comment

by:mouatts
ID: 10785372
>However it takes up too much resources.
Well it will because it is constantly doing something.
The only way that you can introduce a delay without chewing up the processor is if a timer is set that prevents execution of the thread. As you cannot delay the actual thread that is processing the ASP page you will need to shell out to create a thread that can be suspended (ie something along the lines of what anderson22 said).

I've had a look at MSN and I can't see anything that looks like server push?

Steve
0
 
LVL 4

Expert Comment

by:anderson22
ID: 10786052
The sleep, will cause the current thread to pause.  If you setup your asp application to run in an isolated environment, then it will only cause the current application to sleep.

-rca
0
 
LVL 11

Expert Comment

by:mouatts
ID: 10786427
anderson22: Actually I don't think that the isolated environment is important because each page being executed will be within its own thread.
0
 
LVL 4

Expert Comment

by:anderson22
ID: 10787222
mouatts:

>>because each page being executed will be within its own thread<<

I agree. That sounds correct.

-rca
0
 

Author Comment

by:yobyfed
ID: 10794676
Thanks alot guys, Ive managed to get it working using andersons method..

The 64k problem Ive worked out, Its only in the first chunk needs to be greater than 64k's So i send a decoy header to prevent it.

And btw, I meant MSN Messenger mouatts, soz bout that.
0

Featured Post

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
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…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

762 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