In the code below there is a HttpTaskAsyncHandler that calls doit that first delays 5 seconds and writes a string out to browser.
If I have two browser tabs open and call this page on both. The first responds in 5 seconds and the second in 10.
Why does the second request wait for first to complete? The delay was just to represent time taken to do work.
public class MyHandler : HttpTaskAsyncHandler
{
public override bool IsReusable
{
get
{
return true;
}
}
public override Task ProcessRequestAsync(HttpContext p_ctx)
{
return doit(p_ctx);
}
static int _count = 0;
async Task doit(HttpContext p_ctx)
{
await Task.Delay(5000);
p_ctx.Response.Write("doit " + (++_count).ToString());
}
}