Each time an HTTP request is received by IIS, it forwards it to the ASP.NET
worker process. Then does the ASP.NET worker process in turn start a new
thread for each HTTP request it serves (from a pool of thread for example).
Or are all HTTP requests served by the same thread?
An other question is related to static members. A static member in a class
will have the same value across all its instance. But for example if 2
instances of the class are in 2 different threads, will the static member
still share the value or not? If I remember well, in Java, static member do
not share the same value between different threads and I would like to know
if it is the same thing in C# or not.
If anyone got a good link explaining one of both of the 2 topics above that
would be great too !
Thanks in advance,
Francois
I believe they're served by the thread-pool.
> An other question is related to static members. A static member in a class
> will have the same value across all its instance.
It's not that it's shared across all instances - it's that the member
belongs to the type rather than to any instance.
> But for example if 2
> instances of the class are in 2 different threads, will the static member
> still share the value or not? If I remember well, in Java, static member do
> not share the same value between different threads and I would like to know
> if it is the same thing in C# or not.
It's the same in C# as in Java, but you remember Java incorrectly.
Static members are shared across threads.
--
Jon Skeet - <sk...@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Do you know if there is there any way to set some sort of a type value that
will be limited to the scope of a thread only? or is that impossible to do?
Tx in advance and tx again for your answer.
Francois
"Jon Skeet [C# MVP]" <sk...@pobox.com> wrote in message
news:MPG.1c30aa174...@msnews.microsoft.com...
I'm not sure what you ultimately want to accomplish, but in ASP.NET
you generally want a value around that is tied to a specific request,
not a specific thread. To do this you can use the Context.Items
collection.
--
Scott
http://www.OdeToCode.com/blogs/scott/
Alternatively, use the [ThreadStatic] attribute
(ThreadStaticAttribute). It's only available on static variables
(AFAICT), but it keeps one variable per thread.
in .net, static data is shared across all thread (unless the ThreadStatic
attribute is used, which then uses TLS). due to aps.net thread agility
mentioned above, you can not use this method.
-- bruce (sqlwork.com)
"Francois" <fran...@bettinghouses.com_NOSPAM> wrote in message
news:uQ3AXok5...@tk2msftngp13.phx.gbl...
Best regards,
Francois.
"bruce barker" <nospam...@safeco.com> wrote in message
news:%2387adwr...@TK2MSFTNGP09.phx.gbl...