我想在我的应用程序启动时启动一个 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>
