문제

If I declare a static field in a type instantiated within an ASP.NET application, hosted within IIS, is the same variable (i.e. same memory location) used by all of the worker threads used by IIS, opening up concurrency issues?

도움이 되었습니까?

해결책

Yes. Static variables are shared across an entire AppDomain, which means all worker threads that live in that AppDomain share the same "instance" of that variable.

Static variables are generally a poor choice for highly concurrent applications, like web apps. Depending on your specific scenario, consider session variables.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top