Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Equvalent of SetTimeout for server-side?

Status
Not open for further replies.

nazzaro

Programmer
Jun 28, 2000
31
US
I am trying to impliment the equivalent of SetTimeout to execute a function on a timed interval, server-side.<br><br>Specifically, rather than include code in individual loops, I would like to check every second or so to see if the client is still connected, something like (which doesn't work):<br><br>Function StillWorking()<br><br>&nbsp;&nbsp;if working=1 then<br>&nbsp;&nbsp;&nbsp;&nbsp;if response.isclientconnected=false then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;response.end<br>&nbsp;&nbsp;&nbsp;&nbsp;end if<br>&nbsp;&nbsp;&nbsp;&nbsp;intTimerId = SetTimeout(&quot;StillWorking&quot;, 1000)<br>&nbsp;&nbsp;end if<br><br>end function<br><br>By the way, note &quot;response.end&quot; (works) which causes the script to end (more reliable way, I think, than using EXIT DO or EXIT FOR if you want to stop the script immediately).<br><br>Is there any way to do a &quot;timer event&quot; in server-side VbScript?<br>
 
Dear nazzaro,<br><br>HTTP is a stateless non-persistent connection oriented protocol. Even though version 1.1 allows for keeping the connection open it is designed for use by the browser only so that it doesn't have to create a new connection for every file(resource) on a page. This optimizes total page download time.<br><br>You can make your code 'sleep' if you want before sending more response data to the browser but it is all part of the single request/response pair that initiated the instance of your code.<br><br>Using a 'push' design is the only way to truly perform server side initiated client updates.<br><br>Hope this helps<br>-pete
 
Sorry, but I apparently, didn't explain the application well enough.<br><br>The application queries a database, does lot's of data manipulation and sends a table to the client.<br><br>The
 
Sorry, but I apparently, didn't explain the application well enough.<br><br>The application queries a database, does lot's of data manipulation and sends a table to the client.<br><br>The &quot;timer&quot; that I want to use has nothing to do with the client.&nbsp;&nbsp;I need it to interrupt the server processing of the script periodically BEFORE the table gets sent to the client.<br><br>Would it be possible to use &quot;Timer1 = Server.CreateObject (&quot;blah1.blah2&quot;)&quot; to make a timer control available to asp?<br><br>If so, what would the &quot;blah1&quot; and &quot;blah2&quot; be (to use the regular VB timer control, which should be on the server I'm currently using since VB6 is installed there)?
 
nassaro,<br><br>&gt; Would it be possible to use &quot;Timer1 = Server.CreateObject (&quot;blah1.blah2&quot;)&quot; to make a timer control available to asp?<br><br>I bet you could create an ActiveX timer in ASP, but were are you going to catch the timer event? ASP processing is not asynchronous!<br><br>&gt; I need it to interrupt the server processing of the script periodically <br><br>You would have to be in a different thread to do that and ASP scripts are not threadable (is that a word?). I mean you can't create a new thread from your script to watch and interrupt the main thread of your script.<br><br>-pete
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top