AsyncManager.Parameters["headlines"] = value; is assigning headlines value. But headlines are become null when NewsCompleted Method is being called.
public void NewsAsync(string city)
{
AsyncManager.OutstandingOperations.Increment();
NewsService newsService = new NewsService();
newsService.GetHeadlinesCompleted += (value) =>
{
AsyncManager.Parameters["headlines"] = value;
AsyncManager.OutstandingOperations.Decrement();
};
newsService.GetHeadlinesAsync(city);
}
public ActionResult NewsCompleted(string[] headlines)
{
return View("News", new ViewStringModel
{
NewsHeadlines = headlines
});
}
1.)How can i debug this?
2.)And also when OutstandingOperations count become 0, framework calls my actionCompleted method, by requesting new thread from thread pool. When this actionCompleted method is called, I looked into call stack and have no idea that what is exactly happening behind. I mean how the framework knows it should call this particular actionCompleted method with this parameter from AsyncManager?
Thanks for the help.