When I create a Dataflow Block I specify its MaxDegreeOfParallelism
like this:
...New ExecutionDataflowBlockOptions With
{.MaxDegreeOfParallelism = System.Environment.ProcessorCount - 1}...
Is any way to change it later?
No, you can't do that.
What you can do is to create the block with a high enough MDOP (possibly Unbounded
) and use SemaphoreSlim
to limit the degree of parallelism to what you actually want.
Then, when you want to change the degree of parallelism, call Release(int releaseCount)
(to increase it) or await WaitAsync()
in a loop (to decrease it).