Example of Asynchronous page processing in ASP.net webforms (.NET 2.0) -


can provide me simple example of asynchronous page processing in asp.net webforms 2.0 (i'm using vs 2010, new syntax lambdas ok)?

i have long running requests don't want tying iis threads.

for simplicity's sake, let's current code looks this:

protected void page_load(object sender, eventargs e) {     string param1 = _txtparam1.text;     string param2 = _txtparam2.text;      //this takes long time (relative web request)     list<myentity> entities = _myrepository.getentities(param1, param2);      //conceptually, iis bring new thread here can     //display data after has come back.     dostuffwithentities(entities);  } 

how can modify code asynchronous? let's assume set async="true" in aspx page.

edit

i think figured out how i'm looking for. i've put example code in answer here. feel free point out flaws or changes can made.

i asked folks on asp.net team. here's emailed response me, , now, you.

all code ends doing spinning new thread , performing delegate invocation on thread. there 2 threads running: request thread , new thread. hence sample has worse performance original synchronous code have had.

see http://www.asp.net/web-forms/tutorials/aspnet-45/using-asynchronous-methods-in-aspnet-45 sample on how write , consume async methods in asp.net.


Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

aspxgridview - Devexpress grid - header filter does not work if column is initially hidden -

c# - How to execute a particular part of code asynchronously in a class -