Reputation:
I was wondering if it is possible to somehow make parallel.for or parallel.foreach consume threads that only are assigned/created by a user. Is this even possible?
Upvotes: 0
Views: 105
Reputation: 1502406
You can use an overload which has a ParallelOptions
parameter (such as this one for Parallel.For
), and create such an options object using a custom TaskScheduler
. It's not going to be terribly easy, admittedly... but it's doable.
For more information about task schedulers, see the MSDN section about them and some samples.
Upvotes: 1
Reputation: 887797
You can create your own TaskScheduler
that somehow passes the delegates to your threads.
Upvotes: 0