.net - Enumerators and Thread-safety -


Just to ensure that I have this code:

  this.allObjects = [Some linq query];  

And there are two ways that both read (not modified) this IEnumerable, are they safe to call in parallel? Should it be safe to just loop through an IEnumerable?

It depends on the implementation of the calculator, but in most cases, it is safe.

A note though: pseudocode, as you do, does not actually do anything (due to suspended execution). The LINQ query will only be executed when you use allObjects (or if you make some calls to the toList () on the LINQ query).


Comments

Popular posts from this blog

MySql variables and php -

url rewriting - How to implement the returnurl like SO in PHP? -

Which Python client library should I use for CouchdB? -