Re: Strange Behavior
- From: "Marc Gravell" <marc.gravell@xxxxxxxxx>
- Date: 27 Jul 2006 06:16:36 -0700
Well, as presented it seems to just about work for me - i.e. the value
increments, but I suspect you are hitting one of the following:
1: value-type handling: if the struct is accessed e.g. through a
property, then the value will be cloned, with you updating the separate
copy
2: volatility: another thread looking at this field directly in a tight
look may not notice the change i.e. the value might be in a register
My first question would be: why is this a struct? It feels like it
should be a class, since you seem to want to share it between callers
(which structs are not geared up to do).
Also - (advisory only) - a: accessing fields directly (rather than
through properties) isn't all that recommended; b: since it is static
you may need to make this thread safe (synchronised access) if you are
ever going to do anything complex with threading, otherwise various
gotchas apply. Sounds like this may not be an issue.
But try making it a class; I suspect this will fix everything.
Marc
.
- References:
- Strange Behavior
- From: Jon Vaughan
- Strange Behavior
- Prev by Date: Re: select string for oleDB
- Next by Date: Re: Add VB.NET reference to C#
- Previous by thread: Re: Strange Behavior
- Next by thread: Strange Behavior
- Index(es):
Relevant Pages
|