There are two questions on here which both have highly-upvoted, but seemingly contradictory answers.
What is the actual scope of a static variable?
In my case let's say I have a WCF service running under IIS. Several servers with a load balancer in front. One Site on each server, one App Pool as well. Let's say there's a static variable stored in the class which implements the service.
Will the variable persist across the worker process only? The app pool? The server? I tried to research it but found two competing answers on here.
Under this post: IIS app pools, worker processes, app domains
The reply says "Each worker process is a different program that's run your site, have their alone [own?] static variables"
Yet under this post: Lifetime of ASP.NET Static Variable
The reply says "The static variables are per pool"
Maybe I just don't understand the posts, but they seem contradictory?
It appears I have several worker processes running when I checked. Hence my question.
Any help would be appreciated. I am trying to refactor some stuff away from using static variables since it seems risky and exposes concurrency problems but I am very uncomfortable proposing changes without understanding the current behaviour. Thanks!