Frage

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?

War es hilfreich?

Lösung

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

Andere Tipps

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.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top