我想在我的应用程序启动时启动一个 System.Threading.Timer
(也许部署是正确的词)。我看到您可以使用 Application_Start()
但这只是 fired once the first request comes to the application .我需要在应用程序运行时立即启动计时器,以便即使用户没有与网站交互,它也可以检查要处理的工作。如何让应用程序在启动并运行后启动计时器?
最佳答案
您可以为 AlwaysRunning
使用新的 ASP.Net 4 模式。这样就不会等待第一个请求开始
<applicationPools>
<add name="MyAppWorkerProcess" managedRuntimeVersion="v4.0"
startMode="AlwaysRunning" />
</applicationPools>
关于c# - Web 应用程序启动时启动计时器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3000781/