user349026
user349026

Reputation:

Can I make Parallel.For consume user defined threads? C#

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

Answers (2)

Jon Skeet
Jon Skeet

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

SLaks
SLaks

Reputation: 887797

You can create your own TaskScheduler that somehow passes the delegates to your threads.

Upvotes: 0

Related Questions