views:

148

answers:

1

I know that ASP.NET will execute a request on a single thread from a pool. Is the inverse true? Will a single ASP.NET request exclusively hold a worker thread until the request completes, or will ASP.NET re-use the same thread between multiple concurrent requests?

+4  A: 

Even your first statement is not entirely true.

ASP.NET can exhibit thread agility - different parts of a request's lifecycle can (in some cases - usually if some requests are long-running, I believe, or if you're responding asynchronously) run in different threads. See this article (archived) for more information. Unfortunately I haven't seen very much in the way of clear, unambiguous and authoritative documentation on this topic :(

Jon Skeet
Yes, but it should be mentioned that it only happens if you do it explicitly, which in turn requires Async="true" insite the <%Page%> tag.
erikkallen
Nope, I've seen this happen without explicitly using async. I used the "technique" mentioned in the linked article - long sleeps.
Jon Skeet
Great links, thanks. According to this, it will switch on some long-running requests or under heavy traffic without any explicit action by the developer. The HTTPContext is transferred but ThreadStatic values are not, which is mostly what I was wondering about.
flatline
@flatline: That's mightily convenient, that by not actually answering your question, I happened to answer what you were really after ;)
Jon Skeet