C
Chris Mullins [MVP]
I've been really leveraging the ReadOnlyCollection class the last few weeks,
figuring that it works exactly as it's name describes.
Yesterday I was rudely reminded that reading the documentation for a class
is very important, and that making silly assumptions is also bad.
It turns out the ReadOnlyCollection isn't readonly at all, and that
iterating over it isn't a good thing. I looked all over the Web and various
Newsgroups for other people who have run across this, and all of the
examples I found were wrong. Many, many people have made the same mistake
that I did.
http://www.coversant.com/Default.aspx?tabid=88&EntryID=34
In a nutshell: The ReadOnlyCollection class is not thread safe. If a
different thread changes the underlying IList<T> then the contents of the
ReadOnlyCollection change, and all of the standard threading problems arise.
The Documentation says exactly this, so it's simply a case of failing to
RTFM.
figuring that it works exactly as it's name describes.
Yesterday I was rudely reminded that reading the documentation for a class
is very important, and that making silly assumptions is also bad.
It turns out the ReadOnlyCollection isn't readonly at all, and that
iterating over it isn't a good thing. I looked all over the Web and various
Newsgroups for other people who have run across this, and all of the
examples I found were wrong. Many, many people have made the same mistake
that I did.
http://www.coversant.com/Default.aspx?tabid=88&EntryID=34
In a nutshell: The ReadOnlyCollection class is not thread safe. If a
different thread changes the underlying IList<T> then the contents of the
ReadOnlyCollection change, and all of the standard threading problems arise.
The Documentation says exactly this, so it's simply a case of failing to
RTFM.