Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

13
  • So true about volatile. Spent countless of hours trying to get a 100% accurate understanding of it, but I'm still not sure I get it. Commented Nov 26, 2010 at 14:51
  • I had a look at volatile a few days ago (simple-talk.com/community/blogs/simonc/archive/2010/11/24/…), and I couldn't find any documentation on it that wasn't contradictory or misleading. In particular, the CLR docs on the volatile. prefix seem to be completely different to what the C# spec says on volatile. It would be nice to get the 'official' view from a Microsoft CLR person at some point... Commented Nov 26, 2010 at 14:57
  • @thecoop: Yeah. I used to go with the idea that a write to a volatile variable immediately went to main memory, and a read always came from main memory, effectively. I don't think it's that simple, and I get very confused :( Best left to the experts, IMO. Commented Nov 26, 2010 at 15:00
  • In my code, I'm actually trying to read from a Dictionary object. So potentially my update code will out the Dictionary object as it's being read (by some internal routines in the dictionary object) , and I guess might yield unexpected results Commented Nov 26, 2010 at 15:13
  • @Mark 909: If it's a plain Dictionary<TKey, TValue> then that's not thread-safe anyway. Commented Nov 26, 2010 at 15:23