首页 >> 文档 >> ASP专题

编写ASP定时组件

发布日期:2008-07-21最近更新:2008-07-21来源:BHCODE作者:

编写ASP定时组件

 

Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private m_set As Long
Public Property Get setup() As Long
  setup = m_set
End Property
Public Property Let setup(strset As Long)
  m_set = strset
End Property
Public Function Sleeptime()
  Sleep (setup)
End Function

  编译后下,就生成timer.dll组件。我们把它复制到windows目录下,在MS-DOS方式中进行注册,输入:c:\windows\regsvr32 timer.dll 即可。

现在你就可以在ASP里调用它了,具体代码如下:
<html>
<title>精彩春风之定时组件调用</title>
<head>
</head>
<body>
<%
Server.ScriptTimeOut=3600
' 将脚本默认执行时间90秒该为3600秒,否则程序会中断
set obj=server.createobject("timer.sleep")
' 参数1000为线程挂起一秒钟,可以任设
obj.setup=1000
do while true
    response.write "("&right(Time,8)&")现在计时为<font color=red>"&application("time_count")
&"</font><br>"
  obj.sleeptime
  application("time_count")=application("time_count")+1

  If Not Response.IsClientConnected Then
    set obj=nothing
    session.abandon
  End If
loop
%>
</body>
</html>

本周推荐
MORE
热点关注
MORE