1 namespace System.Web.Mvc.Async {
3 using System.Collections.Generic;
5 public abstract class AsyncActionDescriptor : ActionDescriptor {
7 public abstract IAsyncResult BeginExecute(ControllerContext controllerContext, IDictionary<string, object> parameters, AsyncCallback callback, object state);
9 public abstract object EndExecute(IAsyncResult asyncResult);
11 public override object Execute(ControllerContext controllerContext, IDictionary<string, object> parameters) {
12 // execute an asynchronous task synchronously
13 IAsyncResult asyncResult = BeginExecute(controllerContext, parameters, null, null);
14 AsyncUtil.WaitForAsyncResultCompletion(asyncResult, controllerContext.HttpContext.ApplicationInstance); // blocks
15 return EndExecute(asyncResult);
18 internal static AsyncManager GetAsyncManager(ControllerBase controller) {
19 IAsyncManagerContainer helperContainer = controller as IAsyncManagerContainer;
20 if (helperContainer == null) {
21 throw Error.AsyncCommon_ControllerMustImplementIAsyncManagerContainer(controller.GetType());
24 return helperContainer.AsyncManager;