|
|

tips menu | printable single page versionNote: this
is my old ASP tips page and is no longer supported. See the new Visualize web site..
ASP Coding for Performance - IsClientConnected - avoiding stray tasks
This is useful to use to ensure that the client is still fetching the page that is currently processing. For example, consider the following classic loop which simply goes through all the records in a recordset:
Do While Not rsTest.EOF
' process and display each record
' etc....
rsTest.MoveNext
Loop
Let's say there are 5000 records to process. What if the user stops the page before it is fully finished - the script will continue to run, when the user has long gone! The following rectifies the situation:
Do While (Not rsTest.EOF) And (Response.IsClientConnected)
' process and display each record
' etc....
rsTest.MoveNext
Loop
This will loop until end of file or the user selects the stop button. Excellent, just what we want. ;-)
DISCLAIMER: Note these pages are a free resource for anyone wishing to reference them. Although every care is taken to ensure their correctness, the author takes no responsibility for any errors or problems that may occur through their use, or indeed misuse. These pages are copyight of Dave Clarke, Visualize Software Ltd 1997-2000 (all rights reserved).
© Copyright
Dave Clarke, 1996-2008
|