> 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.

It would appear that the attribute is just tied to the thread so the potential
exists for multiple requests to affect the threadstatic variable. I was always
aware of the asp.net thread pooling, but somehow it surprises me that multiple
requests might hang on to the same thread *out of sequence*. I guess I thought
that the pool was only used to reduce the overhead of starting and disposing of
threads. Maybe I'm reading too much into this, and that it's just that a
threadstatic attribute does not imply any mechanism to clear the variable in a
thread pool.

I guess this comes back then to CallContext in System.Remoting.Messaging. It
appears that this is actually what asp.net uses to do it's httpcontext. There
was just the "thread" about that with terms of abuse thrown around ;-)

It seems like CallContext is what we want, but is there an elegant way to clean
up a thread when your done with it, epecially if what you want to do is work
within one chain of execution, but can't control the life of the thread?



=====
Philip - http://blogs.xcskiwinn.org/panmanphil
"There's a difference between righteous anger and just being crabby" - Barbara

===================================
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