Article ID: 182892
Article Last Modified on 5/2/2006
<%@ LANGUAGE="VBSCRIPT" %>
<%
'
' !!! WARNING !!!
'
' This page has code in it that may use 100% CPU cycles for at least
' 30 seconds. Do not run this code on a production server; restrict
' its use to a test server.
'
Function IsConnectedAfter(Seconds)
Dim StartTime 'time the function started
Dim PauseTime 'time the pause loop started
' Use PerfMon to monitor the CPU cycles on the Web server. You
' will notice that if you click stop in the browser, the CPU
' will settle down sooner than if the loop had continued.
IsConnectedAfter = True
StartTime = Now
Do While DateDiff("s", StartTime, Now) < Seconds
PauseTime = Now
Do While DateDiff("s", PauseTime, Now) < 1
'Do Nothing
Loop
Response.Write "."
If Response.IsClientConnected = False then
IsConnectedAfter = False
Exit Function
End If
Loop
End Function
%>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual InterDev 1.0">
<META HTTP-EQUIV="Content-Type" content="text/html; charset=iso-8859-1">
<TITLE>Document Title</TITLE>
</HEAD>
<BODY>
<h1>!!! WARNING !!!</h1>
<p>This page has code in it that may use <b>100% CPU cycles</b>
for at least 30 seconds. Do not run this code on a production
server; restrict its use to a test server.
<p>Use PerfMon to monitor the CPU cycles on the Web server.
Press STOP in the Web browser, and you will see that the
CPU cycles will settle down sooner than they would have
without checking the IsClientConnected property.
<HR>
<%
If IsConnectedAfter(30) then
Response.Write "<p>The client is still connected</p>"
Else
'The browser is no longer connected. This would be a
'good place to abort any transactions, clean up any
'variables, and so forth.
End If
%>
</BODY>
</HTML>
Keywords: kbhowto kbwebserver KB182892