Ben*_*key 6 c# asynchronous asp.net-mvc-2
在ASP.NET MVC 2异步控制器中,我们可以这样做:
public class SomeController : AsyncController
{
[Blurb]
public void FooAsync()
{
this.AsyncManager.OutstandingOperations.Increment();
Task.Factory.StartNew(
() =>
{
this.AsyncManager.Parameters["result"] = new BazResult();
this.AsyncManager.OutstandingOperations.Decrement();
});
}
public ActionResult FooCompleted(ActionResult result)
{
return result;
}
}
Run Code Online (Sandbox Code Playgroud)
我的问题是,在这种情况下,动作过滤器"Blurb"是否异步执行?换句话说,它的同步特性是自动包装成异步调用吗?
我查看了AsyncControllerActionInvoker的内部情况,看起来它确实将它们包装到一组异步调用和延续中。它调用BeginInvokeActionMethodWithFilters,后者又设置InvokeActionMethodFilterAsynchronously。
对于那些好奇的人,源代码位于 codeplex 上。
归档时间: |
|
查看次数: |
597 次 |
最近记录: |