HomeController/Index 中的异步控制器

发布于 2024-12-08 20:18:08 字数 105 浏览 2 评论 0原文

由于索引是网站的默认登陆区域,因此将家庭控制器设置为异步控制器是个好主意吗?

在什么场景下我可以利用AsyncControllers?

谢谢,

瑞安

since Index is the default landing zone for a website, is it a good idea to make the home controller an async controller?

In what scenario can I take advantage of AsyncControllers?

Thanks,

Ryan

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

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

发布评论

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

评论(2

浮生未歇 2024-12-15 20:18:08

既然索引是网站的默认登陆区域,那么它是一个好的选择吗?
有想法让家庭控制器成为异步控制器吗?

不,这不是一个好主意。

在什么情况下我可以利用 AsyncControllers?

当您执行密集型 I/O 任务并且您可以从 I/O 完成端口(例如数据库调用、Web 服务调用等)受益时,我建议您阅读 以下文章可以更好地理解这个概念。它是关于异步 ASP.NET 页面,但异步控制器的工作原理完全相同。

since Index is the default landing zone for a website, is it a good
idea to make the home controller an async controller?

No, it isn't a good idea.

In what scenario can I take advantage of AsyncControllers?

When you have actions that perform intensive I/O tasks and for which you could benefit from I/O Completion ports such as database calls, web service calls, ... I would recommend you reading the following article for better understanding the concept. It's about async ASP.NET pages but async controllers work exactly the same.

梦醒时光 2024-12-15 20:18:08

仅当操作需要很长时间才能完成时才应使用异步控制器。异步并不会神奇地提供更好的性能,事实上,它的性能比普通控制器更差

然而,异步控制器允许您更好地利用资源,特别是线程池。使控制器异步允许线程返回到线程池以服务其他请求。

如果您的请求没有执行任何耗时的操作,那么您只是无缘无故地增加了开销。

You should only use asynch controllers when an operation will take a long time to complete. Asynch does not magically give better performance, in fact, it will perform WORSE than a normal controller.

Asynch controllers, however, allow you to make better use of resources, in particular the thread pool. Making a controller asynch allows the thread to be returned to the thread pool to service other requests.

If your request doesn't do anything time consuming, then you're just adding overhead for no reason.

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