Re: What is the scope of a 'static' variable?

I think I confused the issue by not understanding the managed code
architecture. After doing some reading just now, as I understand it, an
'application domain' is what the common language runtime defines as the
boundry for object activations within the same scope. Then MS defines that
scope as the application scope. With that, they also say that multiple
application domains can exist in a single process...this was the area that
confused me with regard to this initial idea of how far 'static' variables
extend. So it looks like the old application scope/domain is the key
here....only one instance of a static variable will exist in the application
domain for all object instantiations...this is the conclusion. But what
prompted this is the following work that I am trying to make robust:

I am trying to do is create an orderly way to access XML files which really
act similarly to tables in a database. There are multiple control files in
multiple directories which are collectively related to a higher level folder
with another control file....e.g. similar to a parent-child table
relationship schema. To access these files currently I use something like

private static object _lockCtrlFileHandle = new object();

and then in various methods:

{ something...

The problem (I think but am not sure) with this approach is that I don't
think it will scale well and it may actually come to a screeching halt with
a large number of users(deadlock). But another question that comes up is how
access to the files should be handled by different applications...the
'static' object lock handle above only works for the application it is
running in. (I think...)

But the next question that comes to mind is that Windows already manages
file handles. It gives an error message when accessing the same file when it
is opened exclusively by another application. I think this is actually built
into file IO perhaps in BIOS.

So maybe the question is really how do I design a file access system that
keeps an orderly access and control for the information thats in those

Thanks for your response. If you have more ideas about this I would
appreciate hearing them.


Gery D. Dorazio
Development Engineer

EnQue Corporation
1334 Queens Road
Charlotte, NC 28207
(704) 377-3327
"Michael C#" <xyz@xxxxxxxxxx> wrote in message
> Hmmm... static is not a scope modifier itself. It can be used with scope
> modifiers like 'public' though. The scope of the static variable is
> whatever you defined it as with your scope modifier... A public static
> variable would have the same scope as a public variable. Not sure if that
> answers your question, but I'm not quite sure I understand the question
> :( Sorry bout that, if it doesn't...
> "Gery D. Dorazio" <gdorazio@xxxxxxxxx> wrote in message
> news:OMYaUn$XFHA.3096@xxxxxxxxxxxxxxxxxxxxxxx
>> Gurus,
>> If a static variable is defined in a class what is the scope of the
>> variable resolved to for it to remain 'static'? For instance, lets say I
>> create a class library assembly that is strongly name which contains the
>> class where the static variable is defined. This library can be
>> referenced by multiple projects. I am fairly sure the static variable
>> does not survive across the application boundry but does it within the
>> application boundry and/or the domain boundry? Maybe another way to word
>> this question is this: To what scope is an instance object defined?
>> Thanks,
>> Gery
>> --
>> Gery D. Dorazio
>> Development Engineer
>> EnQue Corporation
>> 1334 Queens Road
>> Charlotte, NC 28207
>> (704) 377-3327