views:

47

answers:

1

According to the answer to this question, there is no way to effectively use LINQ for IO bound tasks. Is there a way to gain better control, or is LINQ just not suited for such tasks?

+3  A: 

I don't agree with your conclusion. In the other question, Luke stated that:

From the MSDN documentation: "Degree of parallelism is the maximum number of concurrently executing tasks that will be used to process the query". WithDegreeOfParallelism is just a hint that PLINQ should use no more than n threads.

The fact that Plinq only decides to use two threads for your code instead of ten doesn't mean that it is unsuitable for IO bound tasks. It means (most likely) that two threads is optimal for your code, not ten.

Robert Harvey
But it is not really optimal. Sometimes, I do know better, and need to directly control the number of threads instead of relying on some heuristic in PLINQ.
ripper234
I suspect that the code you are using for testing really does perform optimally with two threads, and that, were there true I/O blocking in your test code, that PLinq would open up more threads.
Robert Harvey
Hmm, I underestimated the heuristics. It changes the number of threads after a few complete iterations.
ripper234