且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

ASP(不是.NET)服务器端计时器

更新时间:2023-11-27 21:48:04




您可以使用setTimeout函数来设置计时器。

执行此操作的语法是:

ID = window.setTimeout(" yourRoutine",5000)

此函数将在执行子程序后执行指定毫秒数。

如果您不想执行子程序清除计时器,可以调用

window.clearTimeout ID


我的目标:

我需要让我的网络应用程序在一定时间内每周两次检查远程网站上的更新。例程将下载给定页面的xml内容,解析它,并检索在我的网站上使用的信息。所以我需要触发按计划间隔执行此操作的例程。

在我看来,我需要一个从global.asa启动的计时器。我真的不在乎它是否每5分钟运行一次(这不是很多服务器负载)并检查时间,如果一周中的某一天和时间是合适的,那么例程应该被触发并且可以检查远程网站以获取我需要的更新信息。

我看过system.time可供.NET人员使用,但我正试图避开.NET,原因很多。我只想说我正在使用旧的ASP并打算保持这种方式。我有什么想法可以完成我的需要吗?

谢谢大家。






你可以使用setTimeout函数设置计时器。

执行此操作的语法是:

ID = window.setTimeout(" yourRoutine",5000)

此函数将在执行子程序后执行指定毫秒数。

如果您不想执行子程序清除计时器,可以调用

window.clearTimeout ID



window.setTimeout?这是一个在带窗口的网页上​​使用的功能,对吗?这对我的应用程序功能有何帮助?我不能在global.asa中使用类似的东西我不相信。我错了吗?我不认为我会像我在最初的帖子中描述的那样使用类似的东西来运行例程,因为没有人会打开窗户;它需要由网站应用程序自动运行。


不幸的是,经典ASP只在加载页面时运行,因此无法设置应用程序计时器。 ASP中的***解决方案是针对每个页面加载,检查它是否是给定时间后的第一个加载。如果是这样,执行你的任务并重置计时器,否则继续。


如果这有帮助,请告诉我。


Jared


My goal:
I need to cause my web application to check for updates on a remote website twice a week around a certain time. The routine would download the xml content of a given page, parse it, and retrieve information for use on my website. So I need to trigger the routine which does this on a scheduled interval.
It seems to me I need a timer that is initiated from the global.asa. I really don''t care if it runs every 5 minutes or so (that''s not a lot of server load) and checks the time, and if the day of the week and time are appropriate, the routine should get triggered and the remote website can be checked for the updated information I need.
I have seen "system.time" available for the .NET folks, but I''m trying to steer clear of .NET for a zillion reasons. Suffice it to say I''m using the old ASP and intend to keep it that way. Any ideas how I can accomplish what I need?
Thanks all.

Hi,

You can use setTimeout function to set the timer.
Syntax for doing this is :
ID = window.setTimeout("yourRoutine" , 5000)
This function will execute your subroutine after specified no of milliseconds.
To clear the timer if you do not want to execute the subroutine you can call
window.clearTimeout ID

My goal:
I need to cause my web application to check for updates on a remote website twice a week around a certain time. The routine would download the xml content of a given page, parse it, and retrieve information for use on my website. So I need to trigger the routine which does this on a scheduled interval.
It seems to me I need a timer that is initiated from the global.asa. I really don''t care if it runs every 5 minutes or so (that''s not a lot of server load) and checks the time, and if the day of the week and time are appropriate, the routine should get triggered and the remote website can be checked for the updated information I need.
I have seen "system.time" available for the .NET folks, but I''m trying to steer clear of .NET for a zillion reasons. Suffice it to say I''m using the old ASP and intend to keep it that way. Any ideas how I can accomplish what I need?
Thanks all.


Hi,

You can use setTimeout function to set the timer.
Syntax for doing this is :
ID = window.setTimeout("yourRoutine" , 5000)
This function will execute your subroutine after specified no of milliseconds.
To clear the timer if you do not want to execute the subroutine you can call
window.clearTimeout ID

window.setTimeout? That''s a function to be used on a webpage with a window, right? How does that help me in an Application function? I can''t use something like that in global.asa I don''t believe. Am I wrong about that? I don''t think I would run a routine like I described in my initial posting using something like this because nobody would be opening a window; it needs to be run automatically by the website application.


Unfortunately, classic ASP only runs when pages are being loaded, so there is no way to set application timers. The best solution in ASP is for every page load, check whether it is the first load after a given time. If so, perform your task and reset the timer, otherwise continue.

Let me know if this helps.

Jared