开发者

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

开发者 https://www.devze.com 2023-03-04 12:30 出处:网络
In ASP.NET MVC 2 async开发者_如何学Pythonhronous controllers, we can do something like this: public class SomeController : AsyncController

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

精彩评论

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