Created
August 13, 2012 13:41
-
-
Save gprasant/3340906 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class HomeControllerAsync : AsyncController | |
{ | |
/// depends on long running service call. | |
public void FindAnswerAsync() | |
{ | |
var wc = new WebClient(); | |
wc.DownloadStringCompleted += (s, e) => { | |
AsyncManager.Parameters["result"] = e.result; | |
AsyncManager.OutstandingOperations.Decrement(); | |
} | |
AsyncManager.OutstandingOperations.Increment(); | |
wc.DownloadStringAsync(new Uri("some_url")); | |
} | |
/// Handles FindAnswer completion. | |
public ActionResult FindAnswerCompleted(string result) | |
{ | |
ViewBag.result = result; | |
return View(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment