AsyncEx
AsyncEx copied to clipboard
Feature request: A task scheduler with a fixed number of threads separate from the main pool
Sometimes, you want to isolate a workload from the main thread pool. For example, when you start a Parallel
loop in a fresh process, this sometimes immediately exhausts the thread pool. This crowds out other work and even stops timers from firing until the pool responds.
I know of no built-in way to achieve this.
I use the WorkStealingTaskScheduler
from the old ParallelExtensionsExtras
for this purpose. The library is long abandoned and not supported.
It should be possible to set the thread priority (maybe through a callback that notified user code when a thread was created so that it can be configured arbitrarily).
A custom thread pool is out-of-scope for this (async-oriented) library.
Generally, most devs handle this by boosting the minimum thread pool count and then using ConcurrentExclusiveSchedulerPair
(which migrated into the BCL from ParallelExtensionsExtras
). Is there a reason that approach wouldn't work for you?
Yeah, that's what I do sometimes. It seems unclean, though, to alter global state for everything that lives in the process to solve a local problem.
I know about using ConcurrentExclusiveSchedulerPair
to limit parallelism but that's not enough here.
If this is out of scope feel free to close.