带有 ASP.NET Web 应用程序的后台任务

发布于 2024-08-08 12:33:02 字数 299 浏览 3 评论 0原文

这是每 x 分钟运行一次后台作业的技术吗: http://msdn.microsoft.com/en-us/library/system.threading.threadpool.queueuserworkitem%28VS.71%29.aspx

那么我会在全局中加载它吗.asax?

Is this the technique to run a background job every x minutes: http://msdn.microsoft.com/en-us/library/system.threading.threadpool.queueuserworkitem%28VS.71%29.aspx

So would I load this in the global.asax?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

灵芸 2024-08-15 12:33:02

另一种方法是拥有一个页面,当访问该页面时,该页面会执行您想要执行的任务。然后,您设置一些流程(许多托管提供商在其控制面板中提供了这样的机制),该流程每 X 分钟简单地点击该页面并强制作业运行。

Another method is to have a page that when accessed, does the task you intend to do. Then you setup some process (a lot of hosting providers provide such a mechanism in their control panel) that simple hits that page every X minutes and that forces the job to run.

狼性发作 2024-08-15 12:33:02

不,Thread.QueueUserWorkItem 用于在线程池外的线程上排队单个工作单元。当此任务运行时,您将从 ASP.NET 中获取一个线程。执行计划任务的最佳方法可能是通过 Windows 服务,但是查看@Heinzi 建议的方法,可能适合没有大量并发用户的站点。

No, Thread.QueueUserWorkItem is for queing up a single unit of work on a thread out of the thread-pool. Whilst this task is running you are taking a thread away from asp.net. The best way to execute scheduled tasks is probably through a windows service, but look into the method suggested by @Heinzi, can be suitable for site that don't have huge numbers of concurrent users.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文