If it does not matter what order the FileMemberEntity
objects are acted on, you can use List<T>
because you are not modifying the list.
If you must ensure some sort of ordering, you can use OrderablePartitioner<T>
as a base class and implement an appropriate partitioning scheme. For example, if the FileMemberEntity
has some sort of categorization and you must process each of the categories in some specific order, you would want to go this route.
Hypothetically if you have
Object 1 Category A
Object 2 Category A
Object 3 Category B
there is no guarantee that Object 2 Category A
will be processed before Object 3 Category B
is processed when iterating a List<T>
using Parallel.ForEach
.
The MSDN documentation you link to provides an example of how to do that.