在每隔几分钟的Global.asax Execute方法 [英] Execute method in global.asax every few minutes

查看:201
本文介绍了在每隔几分钟的Global.asax Execute方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是执行在Global.asax方法文件分钟每x数量的最有效方法是什么?有没有办法让ASP.NET服务器运行一个后台线程,某经过时间后触发一个Tick事件?

What is the most effective way to execute a method in the Global.asax file every x number of minutes? Is there a way to have the ASP.NET server run a background thread that fires a tick event after a certain elapsed period?

推荐答案

您可能在Global.asax的的Application_Start一个计时器,但这不是很灵活,因为你需要做的定时器的应用程序的请求开始。有危险在做它虽然这样,通过Haacked详见:

You could have a timer in the Application_Start of the Global.asax, but this is not very flexible since you need to do a request to the application for the timer to start. There are dangers to doing it this way though, as detailed by Haacked:

做的更好的办法是有一个作为你的ASP.NET应用程序的接口,并有计划间隔调用您的Web服务的窗口服务的Web服务:

A better way of doing it is to have a web service that acts as an interface to your ASP.NET application and have a windows service that calls your web service on scheduled intervals:

下面的更多细节:

这篇关于在每隔几分钟的Global.asax Execute方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆