title: Example of Asynchronous page processing in ASP.net webforms (.NET 2.0)
body: <p>Can someone provide me with a simple example of Asynchronous page processing in ASP.NET Webforms 2.0 (I'm using VS 2010, so new syntax like lambdas are ok)?</p>
  
  <p>I have some long running requests that I don't want tying up IIS threads.</p>
  
  <p>For simplicity's sake, let's say my current code looks like this:</p>
  
  <pre><code>protected void Page_Load(object sender, EventArgs e)
  {
      string param1 = _txtParam1.Text;
      string param2 = _txtParam2.Text;
  
      //This takes a long time (relative to a web request)
      List&lt;MyEntity&gt; entities = _myRepository.GetEntities(param1, param2);
  
      //Conceptually, I would like IIS to bring up a new thread here so that I can
      //display the data after it has come back.
      DoStuffWithEntities(entities);
  
  }
  </code></pre>
  
  <p>How can I modify this code so that it is asynchronous?  Let's assume that I already set async="true" in the aspx page.</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>I think I figured out how to get what I'm looking for.  I've put the example code in an answer <a href="https://stackoverflow.com/questions/4190907/example-of-asynchronous-page-processing-in-asp-net-webforms-net-2-0/4199032#4199032">here</a>.  Feel free to point out any flaws or changes that can be made.</p>