Monday, June 6, 2011

Hybrid approach of using Sync and Async actions in AsyncController

Hi All,

Today i am going to discuss about an intersting aspect or a window of opportunity which opens up when we use and AsycnController, As you might know, an AsyncController class can contain methods /actions which are of type Synchronous or Asynchronous. i.e In an AsyncController class we can have both Synchronous and Asynchronous methods.

Having said that, we also need to stick to one rule, that is if you have a Synchronous method with the name MethodCompleted – then you cant call that method since it wont be having the matching MethodAsync and if you try to call MethodCompleted without the matching MethodAsync the call will be blocked.

Inspite of all these restriction, if you still want to make use of the same ActionName – MethodCompleted – then you can have a method with some different name but decorate the action with the ActionName(“MethodCompleted”)

public ActionResult SomeMethodName()

One another note, you cant explicitly call http://localhost/MethodAsync either through an ActionLink or By using any other Redirections – we always need to do those action invoking by using http://localhost/Method

I hope this helps!.



No comments: