Looking for a little advice on leveraging AsParallel()
or Parallel.ForEach()
to speed this up.
See the method I\'ve got (simplified/bastardized
When using AsParallel(), you need to make sure that your body is thread safe. Unfortunately, the above code will not work. List
is not thread safe, so your addition of AsParallel()
will cause a race condition.
If, however, you switch your collections to using a collection in System.Collections.Concurrent, such as ConcurrentBag