开发者

In ASP.NET MVC 2 asynchronous controllers, do Action Filters execute asynchronously?

In ASP.NET MVC 2 async开发者_如何学Pythonhronous controllers, we can do something like this:

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;
    }
}

My question is, does the action filter "Blurb" in this case execute asynchronously? In other words, is its synchronous nature automatically wrapped into an asynchronous call?


I took a look under the covers at AsyncControllerActionInvoker and it looks like it does indeed wrap them into a set of asynchronous calls and continuations. It makes a call to BeginInvokeActionMethodWithFilters which in turn sets up InvokeActionMethodFilterAsynchronously.

For those who are curious, the source is on codeplex.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜