AsyncController in MVC2.0
-
21-07-2021 - |
Question
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;
}
}
- 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 ???
- Do i required to make changes in my Global.ascx file. like RouteCollection.MapRoute to RouteCollection.AsyncMapRoute
Solution
- 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.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow