.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

asp.net - Javascript/DOM Why is does my form not support submit()? -

sockets - Delphi: TTcpServer, connection reset when reading -

javascript - Classic ASP "ExecuteGlobal" statement acting differently on two servers -