LINQ can be more faster with the availability of multi-core desktops. This can be implemented with minimal impact at the code level with existing code.
Here how it looks like,
Dim arrInt = Enumerable.Range(1, 4000000)
Dim q =
From n In arrant
In my dual core machine it takes around 2693 millisecond. But with a little tweak you can make it faster
From n In arrInt.AsParallel()
Now this takes 1527 milliseconds. Clearly something to think about.
Behind the scene
What happens in this case? All the Where / Select becomes Lambda expression like
arrInt.AsParallel().Where(Function(n) IsPrime(n)).Select(Function(n) n)
When we were using without AsParallel(), Where/Select were coming from Enumerable class. After we have implemented the AsParallel() it now calls the method from ParallelEnumerable class.
ParallelEnumerable class internally implements the new “Task” API.
.NET should detect multi-core functionality at runtime and invoke .AsParallel() automatically.
If someone doesn't want all the processing power, they can could a command to turn PLINQ off.