You do not need to complicate the work using a loop in the pipeline, as in your image, all you need is to save constant data in a variable that is stored between calls to the processing function.
If you use lambda, this variable can be the outisde lambda local variable:
IPropagatorBlock<InputImage, OutputImage> CreateProcessingBlock() { InputImage previousImage = null; return new TransformBlock<InputImage, OutputImage>( inputImage => { var result = Process(inputImage, previousImage); previousImage = inputImage; return result; }) }
If you use the instance method for some object, this variable can be an instance field on this object:
class Processor { InputImage previousImage; public OutputImage Process(InputImage inputImage) { var result = Process(inputImage, previousImage); previousImage = inputImage; return result; } } β¦ new TransformBlock<InputImage, OutputImage>(new Processor().Process)
svick source share