plinq

PLINQ delayed execution

I'm trying to understand how parallelism might work using PLINQ, given delayed execution. Here is a simple example. string[] words = { "believe", "receipt", "relief", "field" }; bool result = words.AsParallel().Any(w => w.Contains("ei")); With LINQ, I would expect the execution to reach the "receipt" value and return true, without ex...

Use Session state within pLinq queries

Hi, I have a fairly simple Linq query (simplified code): dim x = From Product In lstProductList.AsParallel Order By Product.Price.GrossPrice Descending Select Product Product is a class. Product.Price is a child class and GrossPrice is one of its properties. In order to work out the price I need to use Session("exchange_rate...

Why is PLINQ slower than LINQ for this code?

First off, I am running this on a dual core 2.66Ghz processor machine. I am not sure if I have the .AsParallel() call in the correct spot. I tried it directly on the range variable too and that was still slower. I don't understand why... Here are my results: Process non-parallel 1000 took 146 milliseconds Process parallel 1000 took 15...

How can I use plinq to fill an array with strings returned from my "FormatStatus" Method?

This is my first time playing around with linq and I can't quite figure out what I need to search on google to find out what I am doing wrong, so here I am. Here is what I have so far: var formattedStatuses = (from status in _statusCollection select FormatStatus(status)).AsParallel(); ...

Silverlight 4 PLINQ

I have a very simple question. Is it possible to use PLINQ with Silverlight 4 since it seems that it doesn't exist in the most commonly referenced assemblies? ...

NHibernate LINQ + PLINQ

Hi i've just started reading up on PLINQ and find it fasinating. I'm using NHib->Linq in my projects - does anyone know if there's any benefit/problems using PLINQ type queries with NHLinq? w:// ...

Using PLINQ to calculate and update values within the enclosure does not work

I recently needed to do a running total on a report. Where for each group, I order the rows and then calculate the running total based on the previous rows within the group. Aha! I thought, a perfect use case for PLINQ! However, when I wrote up the code, I got some strange behavior. The values I was modifying showed as being modified wh...

Is it OK to try to use Plinq in all Linq queries?

I read that PLinq will automatically use non parallel Linq if it finds PLinq to be more expensive. So I figured then why not use PLinq for everything (when possible) and let the runtime decide which one to use. The apps will be deployed to multicore servers and I am OK to develop a little more code to deal with parallelism. What are t...

How can one manage to fully use the newly enhanced Parallelism features in .NET 4.0?

I am pretty much interested into using the newly enhanced Parallelism features in .NET 4.0. I have also seen some possibilities of using it in F#, as much as in C#. Despite, I can only see what PLINQ has to offer with, for example, the following: var query = from c in Customers.AsParallel() where (c.Name.Contains("customer...

Parallel LINQ implementation in mono?

I was considering trying PLINQ to parallelize some numerical methods which need to be portable. Does Mono implement Parallel LINQ? If so, how does performance compare between .NET and mono. ...

While using ConcurrentQueue, trying to dequeue while looping through in parallel

I am using the parallel data structures in my .NET 4 application and I have a ConcurrentQueue that gets added to while I am processing through it. I want to do something like: personqueue.AsParallel().WithDegreeOfParallelism(20).ForAll(i => ... ); as I make database calls to save the data, so I am limiting the number of concurrent thr...

How to use IObservable/IObserver with ConcurrentQueue or ConcurrentStack

I realized that when I am trying to process items in a concurrent queue using multiple threads while multiple threads can be putting items into it, the ideal solution would be to use the Reactive Extensions with the Concurrent data structures. My original question is at: http://stackoverflow.com/questions/2997797/while-using-concurrent...

PLINQ Aggregate exception I don't understand

Hi I was waching the PLINQ PCD09 presentation by Igor Ostrovsky, and wanted to try to see what I could get out of my CULV laptop. At a point I got a strange exception and I'm not sure what it means. I've condensed the code for better overview. It is the last primes.Sum() that causes the exception and if I make the range small - 8000 - ...

IEnumerable yield return combined with .AsParallel()

I've written some code to try and describe my concern: static void Main(string[] args) { IEnumerable<decimal> marks = GetClassMarks(); IEnumerable<Person> students = GetStudents(); students.AsParallel().ForAll(p => GenerateClassReport(p, marks)); Console.ReadKey(); } GetClassMarks uses yield return in it from my weir...

set multiple properties simultaneously via reflection

Hi. I'm trying to optimize the reflection utilization in my code and I was wondering whether it's possible to set multiple properties of the object at once: Sample usage: private void SetProperties<T>(List<T> objects, List<Tuple<string, object>> propsAndValues) where T:Task { Type type = typeof(T); var p...

Cancelling long-running tasks in PLINQ

I am trying to use the NET 4.0 parallel task library to handle multiple FTS queries. If the query takes too much time, I want to cancel it and continue forward with processing the rest. This code doesn't stop when one query goes over the threshold. I think I'm calling it such that the cancel task and time limit is reached for the whol...

is it ok to use plinq ForAll for a bulk insert into database ?

I'm doing like this: entities.AsParallel().ForAll(o => repository.Insert(o)); is this good, am I going to have more performance with this ? ...

PLINQ Performs Worse Than Usual LINQ

Amazingly, using PLINQ did not yield benefits on a small test case I created; in fact, it was even worse than usual LINQ. Here's the test code: int repeatedCount = 10000000; private void button1_Click(object sender, EventArgs e) { var currTime = DateTime.Now; var strList = Enumerable.Repeat(10, repeatedCount...

Parallelize LINQ Query with Let, Select Keywords

I have the following LINQ query var meshesList= ( from element in elementCoord.Elements let coordinateList = elementCoord.Coordinates select new Plane3D { Pt1 = coordinateList[element.NodeList[0]], Pt2 = coordinateList[element.NodeLis...

PLINQ update failed

Hi, sorry for my English. So, here is my question I'm trying to update DataTable by PLINQ Here is my code DataTable table = new DataTable(); table.Columns.Add(new DataColumn("val", typeof(decimal))); int N = 1000000; for (int i = 0; i < N; i++) table.Rows.Add(new object[] { i }); table.AsEnumerable().AsParallel().ForAll(row => row["...