Reputation: 872
I want to convert a large array of objects in parallel using PLINQ.
var outputs = inputs
.AsParallel()
.AsOrdered()
.WithDegreeOfParallelism(8) // make this number dynamic
.Select(input => MyConverter(input))
.ToArray();
Is there a way to change the number of threads used during execution (custom control)? E.g. by using a callback function like this:
int CurrentThreadLimit() => DateTime.Now.Second / 4 + 1; // callback function (example)
var outputs = inputs
.AsParallel()
.AsOrdered()
.WithDynamicDegreeOfParallelism(() => CurrentThreadLimit()) // How to build this?
.Select(input => MyConverter(input))
.ToArray();
Is something like this possible?
Upvotes: 0
Views: 67