Re: Parallet.ForEach

2013-06-25 Thread Davy Jones
The data above it comes from a yield return, although parallel.foreach was still faster than doing it all in line. List was much much faster, shaved 2000ms off of the process. I read some of the books/articles mentioned and i've been following the parallel blog for ages. But that was back when 4.0

Re: Parallet.ForEach

2013-06-24 Thread Corneliu I. Tusnea
Here is a very good (but very old) presentation about the PFX: http://blogesh.files.wordpress.com/2009/05/getting-the-most-out-of-pfx.pptx Slide 33 has the partitioning details. On Tue, Jun 25, 2013 at 4:45 PM, Corneliu I. Tusnea wrote: > David/Greg, > > Ihe IEnumerable is not an issue with Para

Re: Parallet.ForEach

2013-06-24 Thread Corneliu I. Tusnea
David/Greg, Ihe IEnumerable is not an issue with Parallel.ForEach. The PFX library will look for few other interfaces for your object and decide the partitioning strategy based on that. There are multiple paritioners that will be picked up based on your source: Range (used for IList), Chunk (used

Re: Parallet.ForEach

2013-06-24 Thread Greg Keogh
> > 1. Don't use IEnumerable and Parallel.ForEach, List is much faster. > I don't have the bigger picture here, but IEnumerable and Parallel.ForEach go together like pancakes and ice cream. I'm even getting into the habit these days of making public methods that return collections prefer to retur

Re: Parallet.ForEach

2013-06-24 Thread David Rhys Jones
Hi, I found out what was causing my problems. I replaced the outer List with a ConcurentBag and everything is working fine. 3 Little Tips. 1. Don't use IEnumerable and Parallel.ForEach, List is much faster. 2. Use ConcurrentBag for your results, or one of the other objects in the concurent nam

Re: Parallet.ForEach

2013-06-17 Thread Mark Hurd
I don't know enough about Parallel.ForEach to debug this, although I do think you existing code would need a thead-safe .Add at least. However, could you change this to: ICollection data = GetCustomers(); var customers = data.AsParallel().select( (source) => { DisplayableCustomer destinatio

Re: Parallet.ForEach

2013-06-17 Thread David Rhys Jones
Oops sent too quickly. ICollection data = GetCustomers(); Parallel.ForEach( data, (source) => { DisplayableCustomer destination = new DisplayableCustomer(); Mapper.Map(source, destination); customers.Add(destination); }); later on I order the data. var sorted = from c in customer

Parallet.ForEach

2013-06-17 Thread David Rhys Jones
Hi guys, I'm having a very wierd problem. I've got a collection that I map like this ICollection data = GetCustomers(); Parallel.ForEach( data, (source) => { Davy, The US Congress voted Pizza sauce a vegetable. Don't even try to convince me of anything in the states is sane any more!