How does a static interfere between sessions

G

Guest

Hi

My question is if and how a static variable remains the same state if more than one session of my web site is running. Is the content of my static different at all sessions
or not.
For sample session 1 - Static int = 10
session 2 - Static int = 8
If a third session is running does the static interfere with the other sessions, or not.
I know maybe my quesxtion is a little bit silly, but i have problems in that kind and
ne not sure why.

Thanks a lot for answers
Bye
 
J

John Saunders

Harald said:
Hi

My question is if and how a static variable remains the same state if more
than one session of my web site is running. Is the content of my static
different at all sessions
or not.
For sample session 1 - Static int = 10
session 2 - Static int = 8
If a third session is running does the static interfere with the other sessions, or not.
I know maybe my quesxtion is a little bit silly, but i have problems in that kind and
ne not sure why.

Statics have nothing to do with sessions.

You should almost certainly not be using statics at all.
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,

A static member has application scope, meaning that all the sessions use
the same static member , you should be carefull when using it because of
threading issues, take a look at Skeet's singleton document as an example of
static member problems and how to solve them.

Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

Harald said:
Hi

My question is if and how a static variable remains the same state if more
than one session of my web site is running. Is the content of my static
different at all sessions
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top