发表评论(0)作者:不详, 平台:VB6.0+Win98, 阅读:10411, 日期:2000-11-08
Using Response.IsClientConnected Property to Determine Browser Connection
When a browser requests an ASP page from the Web Server, but does not wait for the entire page to be downloaded, the server continues to process the request, wasting valuable CPU cycles. If running Internet Information Server (IIS) 4.0, you can use the Response.IsClientConnected property to determine whether or not the browser is still connected to the server.
If it is not connected to the server, processing can be stopped to conserve CPU cycles. To do this, request an ASP page that contains the script below and use PerfMon to monitor the CPU cycles on the Web server. Note if you click "Stop" in the browser, the number of CPU cycles will decrease sooner than if the loop had continued.
<%@ LANGUAGE="VBSCRIPT" %>
<%
Function IsConnectedAfter(Seconds)
Dim StartTime
Dim PauseTime
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
%>
When a browser requests an ASP page from the Web Server, but does not wait for the entire page to be downloaded, the server continues to process the request, wasting valuable CPU cycles. If running Internet Information Server (IIS) 4.0, you can use the Response.IsClientConnected property to determine whether or not the browser is still connected to the server.
If it is not connected to the server, processing can be stopped to conserve CPU cycles. To do this, request an ASP page that contains the script below and use PerfMon to monitor the CPU cycles on the Web server. Note if you click "Stop" in the browser, the number of CPU cycles will decrease sooner than if the loop had continued.
<%@ LANGUAGE="VBSCRIPT" %>
<%
Function IsConnectedAfter(Seconds)
Dim StartTime
Dim PauseTime
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
%>