Hi people!

A big question for me:

What is the behaviour of ThreadStatic variables on an ASP.NET Request?
Can I trust that if I set a value on such variable, the value (and the
thread) is the same for all the request (that is, from BeginRequest to
EndRequest)?

I think that this is the case, but some article:

http://scottwater.com/blog/archive/2003/05/23/7463.aspx
http://radio.weblogs.com/0106747/2003/05/23.html#a320

suggests that not:

"In ASP.NET your code is run on a WorkerThread from the 25 or so threads in
the default ASP.NET worker thread pool and the variable that you think is
"personal private to your thread" is personal private...to you and every
other request that this worker thread has been with.  Under load you may
well find your variable modified."

Well, ok, the thread can run one request, and then, another. But, why "under
load you may well find your variable modified" DURING the life of one
request??? (One reader of that article, suggest to me that this is the
intepretation of the "under load" sentence).

Yes, I can use HttpContext, but, I�m curious about the ASP.NET thread pool
behaviour.

Another link:

http://weblogs.asp.net/yreynhout/archive/2003/03/19/4061.aspx

This author trusts that the Thread allocated for the Request, it�s only used
for this request, until EndRequest. This is my position.

If I cannot use securely a ThreadStatic variable during an ASP.NET request,
then I ask:

- This behaviour is extended on any application that uses the automatic
thread pool? Or it is a particular behaviour of the ASP.NET thread pool?
- Where is the "thread switch"?

I apologize some bad english... Me Tarzan... :-)

TIA

Angel "Java" Lopez
http://www.ajlopez.com/

===================================
This list is hosted by DevelopMentor�  http://www.develop.com
Some .NET courses you may be interested in:

NEW! Guerrilla ASP.NET, 17 May 2004, in Los Angeles
http://www.develop.com/courses/gaspdotnetls

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to