Click here to Skip to main content
15,888,968 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
GeneralRe: lock Pin
supercat929-Apr-10 9:11
supercat929-Apr-10 9:11 
GeneralRe: lock Pin
Luc Pattyn29-Apr-10 9:38
sitebuilderLuc Pattyn29-Apr-10 9:38 
GeneralRe: lock Pin
supercat929-Apr-10 13:10
supercat929-Apr-10 13:10 
GeneralRe: lock Pin
Luc Pattyn29-Apr-10 13:56
sitebuilderLuc Pattyn29-Apr-10 13:56 
GeneralRe: lock Pin
supercat930-Apr-10 5:02
supercat930-Apr-10 5:02 
GeneralRe: lock Pin
Luc Pattyn30-Apr-10 5:19
sitebuilderLuc Pattyn30-Apr-10 5:19 
GeneralEnumerators Pin
supercat930-Apr-10 6:12
supercat930-Apr-10 6:12 
GeneralRe: Enumerators Pin
Luc Pattyn30-Apr-10 9:18
sitebuilderLuc Pattyn30-Apr-10 9:18 
Now think about the implementation details of a protected collection. Most if not all collections are built on top of an array, which gets reallocated and copied every time the capacity becomes insufficient, and which gets insert/remove-shifted on each insertion or removal.

Such collection can have any number of users (methods, possibly active on different threads), each possibly holding one or more enumerators; each enumerator has its own state. Now insert or remove a collection item; how could the collection tell which protected enumerators get affected by the modification, and which don't (because they are already past the insertion/removal point). The natural way would be one of these:

1.
inside the collection, keep a collection of current enumerators and check each of them on every modification, not a pretty situation. (Note: there are life issues, probably needs WeakReferences)
2.
for each enumerator, create a copy of the array, basically cloning the collection. An expensive operation.

The current .NET behavior can easily be accomplished by having a "generation number" which is stored in the collection, incremented on every insert/remove, and gets copied into the enumerator when it gets created, then compared on every Next(). None of these are expensive, memory wise of cycle wise.

Smile | :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]

Prolific encyclopedia fixture proof-reader browser patron addict?
We all depend on the beast below.


GeneralRe: Enumerators Pin
supercat930-Apr-10 11:31
supercat930-Apr-10 11:31 
QuestionReference a .NET 3.5 assembly form a .NET 2.0 other assembly: in VS2008 ok, not in VS2010 Pin
Ferdinando Santacroce29-Apr-10 3:22
Ferdinando Santacroce29-Apr-10 3:22 
AnswerRe: Reference a .NET 3.5 assembly form a .NET 2.0 other assembly: in VS2008 ok, not in VS2010 Pin
Not Active29-Apr-10 3:35
mentorNot Active29-Apr-10 3:35 
GeneralRe: Reference a .NET 3.5 assembly form a .NET 2.0 other assembly: in VS2008 ok, not in VS2010 Pin
Luc Pattyn29-Apr-10 4:18
sitebuilderLuc Pattyn29-Apr-10 4:18 
AnswerRe: Reference a .NET 3.5 assembly form a .NET 2.0 other assembly: in VS2008 ok, not in VS2010 Pin
Ferdinando Santacroce29-Apr-10 5:54
Ferdinando Santacroce29-Apr-10 5:54 
QuestionAny Problem with VS 2010 Ultimate? if VS 2008 already exists.. Pin
yadlaprasad29-Apr-10 1:26
yadlaprasad29-Apr-10 1:26 
AnswerRe: Any Problem with VS 2010 Ultimate? if VS 2008 already exists.. Pin
Michel Godfroid29-Apr-10 1:47
Michel Godfroid29-Apr-10 1:47 
AnswerRe: Any Problem with VS 2010 Ultimate? if VS 2008 already exists.. Pin
Not Active29-Apr-10 1:56
mentorNot Active29-Apr-10 1:56 
QuestionSetting DisplayMember & ValueMember with DataTable Pin
massaslayer28-Apr-10 10:21
massaslayer28-Apr-10 10:21 
AnswerRe: Setting DisplayMember & ValueMember with DataTable Pin
Ashfield29-Apr-10 3:39
Ashfield29-Apr-10 3:39 
Questionlinking two tables Pin
kolisa28-Apr-10 1:29
kolisa28-Apr-10 1:29 
AnswerRe: linking two tables Pin
Dave Kreskowiak28-Apr-10 2:17
mveDave Kreskowiak28-Apr-10 2:17 
AnswerRe: linking two tables Pin
Abhinav S28-Apr-10 5:51
Abhinav S28-Apr-10 5:51 
AnswerRe: linking two tables Pin
GauravKP28-Apr-10 9:36
professionalGauravKP28-Apr-10 9:36 
AnswerRe: linking two tables Pin
Peace ON29-Apr-10 1:12
Peace ON29-Apr-10 1:12 
Questionmac number of client system Pin
Gayathri devi sivanesan27-Apr-10 23:24
Gayathri devi sivanesan27-Apr-10 23:24 
AnswerRe: mac number of client system Pin
Michel Godfroid27-Apr-10 23:58
Michel Godfroid27-Apr-10 23:58 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.