Whats the advantage of using AsParallel on an array opposed to just using the array directly?
Code:al.ToArray().AsParallel().ForAll(po => CacheToAppFabric((MyObject)po));
Whats the advantage of using AsParallel on an array opposed to just using the array directly?
Code:al.ToArray().AsParallel().ForAll(po => CacheToAppFabric((MyObject)po));
Your operations in the ForAll will be parallelized. They will execute in parallel (probably dependent on your machine). That's why it's called "ForAll" and not "ForEach".
hth
-nv
She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."
When in doubt, read the FAQ.
Then ask a smart question.
Be careful when using AsParallel. Note that while it is thread safe it does not guarantee operations you may perform from within the LINQ statement are thread safe. Calling a method or extension from within the LINQ statement that is not thread safe invalidates the thread safety of it.
AsParallel also does not guarantee your statement will run faster in all cases such as in the case of calling a query operator that has a lock within it. The lock will limit the LINQ statement's parallel efficiency.
http://www.albahari.com/threading/
Last edited by VirtualAce; 10-03-2012 at 05:40 PM.