AsyncController in MVC2.0

164 views Asked by At

This is something what im trying in MVC 2.0

public class SomeController : AsyncController
{  
    public void SampleAsync()
    {
        AsyncManager.OutstandingOperations.Increment();
        for(int i=0; i=100000; i++)
        {
        // Some Code... This loop is just for the testing.
        }
        AsyncManager.OutstandingOperations.Decrement();        
    }

    public ActionResult SampleCompleted(ActionResult result)
    {
        return result;
    }
}
  1. My question is what will be the parameter to SampleCompleted here it's ACTIONRESULT. I have tried to find out but every where i'll found something different. So what exactly it is ???
  2. Do i required to make changes in my Global.ascx file. like RouteCollection.MapRoute to RouteCollection.AsyncMapRoute
1

There are 1 answers

8
testCoder On BEST ANSWER
  1. The parameter or parameters of SampleCompleted will be variables which you specified in AsyncManager.Parameters - collection:

for example:

public void SampleAsync()
    {
        AsyncManager.OutstandingOperations.Increment();
        for(int i=0; i=100000; i++)
        {

        }
        AsyncManager.Parameters["myvariable"] = "variable value";
        AsyncManager.OutstandingOperations.Decrement();        
    }

    public ActionResult SampleCompleted(string myvariable)
    {
        //myvariable contains value "variable value"
        return result;
    }

2 . You not need to make changes.