c# - How to map ImmutableArray without getting it cast to IEnumerable which is not thread safe? -


so i'm working in multithreaded environment , wan't use immutablearray time because it's thread safe.

unfortunately, immutablearray implements thread unsafe interfaces , select method linq returns ienumerable.

this way, thread safe variable becomes thread unsafe. how map immutablearray immutablearray?

it seems there lot of misunderstandings behind question. need go @ source code select method , learn yield keyword.

second, linq methods made short-lived. have various threads doing various processing tasks. using pipeline situation, want transform data in 1 thread , pass result thread? have careful yield keyword in situation; essentially, need flush (er, realize, lack of better word) collections before passing them next thread actual work done in present thread. in scenario, object ownership kicks in , don't need thread-safe collections.

in short, enumerable returned calling select on immutablearray thread-safe. can realize @ point , won't give errors. of course iterate through data contained in collection @ time called select. won't know newly assigned instances.


Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -