Last active
August 29, 2015 14:05
-
-
Save darrenshrwd/8bf3f7f874bceadcb4b0 to your computer and use it in GitHub Desktop.
Faster controller
This file contains 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
private class SomeModelDemoOnly | |
{ | |
public string Text { get; set; } | |
} | |
// Traditional way | |
public ActionResult Index() | |
{ | |
Thread.Sleep(5000); // Do lots of DB and network stuff | |
var m = new SomeModelDemoOnly() | |
{ | |
Text = "Hello" | |
}; | |
return View(m); | |
} | |
// Faster way | |
public ActionResult FasterIndex() | |
{ | |
var asyncModel = new AsyncModel<SomeModelDemoOnly>(delegate | |
{ | |
Thread.Sleep(5000); // Do lots of DB and network stuff | |
var m = new SomeModelDemoOnly {Text = "Hello"}; | |
return m; | |
}); | |
return View(asyncModel); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment