Question

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?

Était-ce utile?

La solution

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).

Autres conseils

No. You can't change the degree while using the same block.

But, you can set it to a higher number from the start and it will only use as much as it needs (hence Max).

Or you could create a new block with a higher MaxDegreeOfParallelism and start posting your items to it while waiting for the old block to finish.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top