I have a page that has a bunch of widgets on it. Each widget is a view. Right now the widget rendering is done in a foreach loop like so.
public class WidgetCollection : List<Widget>, IPersonalizable
{
public void Render(HtmlHelper html)
{
foreach (Widget w in this)
{
html.RenderAction("Default", "Widget", new { model = w });
}
}
But that means that some of my widgets that render in 800ms because they're IO bound are blocking a bunch of other widgets than only take 100ms to render. So in total the time it takes to render the page is about 3 seconds. I want the page to render in just a bit over 800ms or as close as possible to that.
One idea I had was to call html.Action() to get a string value for each action in parallel but MVC doesn't seem to like rendering views in parallel. I always get an "Object not set to the instance of an object" error when I attempt to do it. The error comes from deep in the MVC stack so I think it is just an MVC bug.
Does anyone have a better idea for increasing page rendering speed?