gpt4 book ai didi

c# - Web 应用程序启动时启动计时器

转载 作者:太空宇宙 更新时间:2023-11-03 17:28:27 24 4
gpt4 key购买 nike

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

参见:http://www.asp.net/learn/whitepapers/aspnet4

关于c# - Web 应用程序启动时启动计时器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3000781/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com