开始在Web应用程序启动定时器 [英] Start timer on web application start

查看:247
本文介绍了开始在Web应用程序启动定时器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的应用程序启动 System.Threading.Timer 当它启动(也许部署是正确的单词)。我所看到的,你可以使用的Application_Start()但这只是<一个href=\"http://stackoverflow.com/questions/1384131/configuring-asp-net-to-start-a-method-before-each-application-start-on-iis/1384144#1384144\">fired一旦第一个请求到达应用。我需要计时器尽快启动的应用程序运行,以便它可以检查工作,即使用户没有与网站交互以处理。我怎样才能获取应用程序启动计时器,一旦它运行起来?

I would like to start a System.Threading.Timer in my application when it launches (maybe deploy is the correct word). I have seen that you can use Application_Start() but this is only fired once the first request comes to the application. I need the timer to start as soon as the application is running so that it can check for work to process even if a user is not interacting with the site. How can I get the application to start the timer once it is up and running?

推荐答案

应用真正开始做火时,应用程序启动并运行。您遇到的问题是,直到接收第一个请求IIS不实际启动应用程序。

Application start actually does fire when the app is up and running. The problem that you are encountering is that IIS does not actually start the application until it receives the first request.

另一个重要的事情要知道:IIS可以将应用停机由于不活动。如果您有需要有运行所有的时间的东西,你可能会寻找一个不同的车辆比ASP.NET应用程序。也许一个Windows服务,甚至是一个计划任务。

Another important thing to know: IIS can shut down your app due to inactivity. If you have something that you need to have running all the time, you might look for a different vehicle than an ASP.NET application. Perhaps a Windows service, or even a scheduled task.

这篇关于开始在Web应用程序启动定时器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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