- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我们计划使用 AsyncController,因为我们的大多数请求将是长时间运行的 I/O 绑定(bind)请求。计划将此处理卸载到 CLR 线程,以便保持最大数量的 IIS 线程空闲来服务新的传入请求。
到目前为止,我们看到的使用 AsyncController 的每个示例都从 AsyncController 的异步操作方法内部异步执行长时间运行的 I/O 绑定(bind)进程。如果您有 2 个或更多可以在 Controller 的异步操作方法中并行运行的操作,我们可以看到这样做的值(value)。
示例: Using an Asynchronous Controller in ASP.NET MVC
在那里,他们异步执行新闻服务。这真的是必需的吗?如果新闻服务是您需要在该操作方法中执行的唯一内容,那么异步执行新闻服务似乎是多余的。在我们的例子中,我们有一个很长的 I/O 进程要运行。我们不能从操作方法的异步版本中同步运行它吗?一旦我们进入 AsyncController 中的异步操作方法,工作是否就已经被传递给 CLR 线程了?
我们再次可以看到,如果我们有更多的工作可以并行运行,我们将如何异步执行进一步的操作。然而,我们只有一个长阻塞操作,并且希望代码保持简单。
我们还看到了另一种策略,使用 Task.Factory.StartNew(),如下所示: Using the AsyncController in ASP.NET MVC 2
我们也非常不愿意这样做,因为它看起来不必要地多余。
最佳答案
是的,我相信你是对的。 documentation说明了初始化异步操作的以下步骤。
The Web server gets a thread from the thread pool (the worker thread) and schedules it to handle an incoming request. This worker thread initiates an asynchronous operation.
The worker thread is returned to the thread pool to service another Web request.
工作线程启动异步操作(即,您不需要在代码中执行此操作)。您引用的示例中使用“额外”异步代码可能是为了说明 AsyncManager.OutstandingOperations.Increment 和 Decrement 的使用(它们通知工作进程即使异步操作可能已返回,操作仍在运行。
关于asp.net-mvc - MVC3 AsyncController - 执行同步 I/O 任务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12539912/
我最近对我的一个 ASP.NET MVC3 Controller 做了一些(相当微不足道的)更改,并将其中一个操作更改为异步操作。基本上我采用了如下代码: public ActionResult My
我是 AsyncController 的新手,请帮助我为什么我无法使用异步从数据库中获取数据: public async Task Index() { Task> objctry = T
在实现 ASP.NET MVC AsyncController 时,xxxCompleted 方法必须是 Public。我想知道这是否意味着可以直接调用 xxxCompleted 方法,或者是否使用
我正在研究 Playframework 概念,我一直坚持使用 AsyncController 示例,该示例说明了以下描述: This controller contains an action tha
我想使用 jQuery ajaxForm 将数据发布到 AsyncController 以触发某些任务。我希望用户能够在此任务完成时继续浏览其他页面。然后我想使用类似 jGrowl 显示状态消息任务完
我需要获取 asp.net MVC 的请求处理时间。我使用 IHttpModule 订阅 onBeginRequest 和 onEndRequest 事件。对于同步 Controller ,它工作得很
我们在 Beta HyperV 环境中的 MVC AsyncController 上收到 TimeoutException。在本地调试时一切正常,但是当我们部署到预生产环境时,我们得到这个错误: [T
我尝试将 id 参数与异步 iactionresult 方法一起使用,但它显示为 null。 如果我从 Controller 继承并使用 - public IActionResult Index(st
我在 ASP.net MVC 中尝试使用异步 Controller 只是为了看看它们是如何工作的。在我的一个异步操作方法中,我想通过循环几次并执行 Thread.Sleep 来模拟长时间运行的方法:
我刚刚在 asp.net mvc 2 中将我的 Controller 转换为 asyncController。(即:将操作方法 About 拆分为 AboutAsync 和 AboutComple
标题很清楚。我现在有一个继承自“Controller”类的 application-BaseController。 对于新的 .NET Framework 4.5 和 ASP.NET MVC 4,我想
AsyncController究竟是怎么做的?避免使用 ASP.NET 工作线程?如果我使用基于事件的模式(伪代码): [AsyncTimeout(60000)] public void WaitFo
我正在尝试将 Controller 中的某些操作转换为在使用 ninject 进行依赖项注入(inject)的 mvc 项目中异步运行。我按照以下步骤继承 AsyncController 并将与“X”
我们计划使用 AsyncController,因为我们的大多数请求将是长时间运行的 I/O 绑定(bind)请求。计划将此处理卸载到 CLR 线程,以便保持最大数量的 IIS 线程空闲来服务新的传入请
我们计划使用 AsyncController,因为我们的大多数请求将是长时间运行的 I/O 绑定(bind)请求。计划将此处理卸载到 CLR 线程,以便保持最大数量的 IIS 线程空闲来服务新的传入请
我有 public class FileController : AsyncController { public ActionResult Download(FormCollection for
我正在使用 AsyncController say 'AbstractAbcContoller' public class AbstractAbcContoller : AsyncController
我正在尝试将此方法 ExportTo3rdParty() 转换为使用 AsyncController: public JsonResult SaveSalesInvoice(SalesInvoice
我正在尝试学习如何在 MVC2 中使用 AsyncController,但那里的文档/教程很少。我希望采用一种普通的 Controller 方法,该方法导出到第 3 方服务的速度非常慢,并将其转换为异
今天,我想在 MVC3 Web 角色的 AsyncController 中模拟等待长时间运行的阻塞进程(5 到 30 秒)。然而,一开始,我只用了 1 秒钟,让事情顺利进行。是的,这样做是否明智值得怀
我是一名优秀的程序员,十分优秀!