I have the below code which calls a workflow. I am wondering if I can changed the controller to be asynchronous using the async ctp.
public ActionResult Index()
Derive from AsyncController
instead of Controller
.
EDIT: You may also be experiencing a known bug where ASP.NET MVC4 will hang if the action returns a completed Task
. You can work around this bug by adding await Task.Yield();
at the top of the action method.
On an unrelated note, this code is more efficient (and shorter, too):
var workflowTask = Task.Factory.FromAsync(invoker.BeginInvoke, invoker.EndInvoke,
input, userState);