网络编程
位置:首页>> 网络编程>> Asp编程>> 如何用Sleep函数编译一个定时组件?

如何用Sleep函数编译一个定时组件?

  发布时间:2010-06-13 14:35:00 

标签:函数,组件,定时

如何用Sleep函数编译一个定时组件?

见下:

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>asp教程之定时组件调用 - asp之家</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>

0
投稿

猜你喜欢

手机版 网络编程 asp之家 www.aspxhome.com