private void Init() { if (_sourceBlock != null) { _sourceBlock.Complete(); } Data = new DataflowVisitor(); _sourceBlock = new BufferBlock <int>() .Hook("Buffer", Data, 50, 300, Colors.SteelBlue); _sourceBlock.AddCommand("Add Item", PostCommand); _targetBlock = new ActionBlock <int>(i => { ReflectBlockExtensions.ProcessItem(i, _sync, _targetBlock.BlockInfo); }, BLOCK_OPTIONS) .Hook("Action", Data, 800, 10); _targetBlock.AddCommand("Release One", ReleaseSingleProcessingTaskCommand); var nullTarget = DataflowBlock.NullTarget <int>() .Hook("NullTarget", Data, 500, 500); _sourceBlock.LinkTo(_targetBlock, LINK_OPTIONS); _unlinkGarbage = _sourceBlock.LinkTo(nullTarget, LINK_OPTIONS); //_toolbar.DataContext = this; }
public void Init() { if (_sourceBlock != null) { _sourceBlock.Complete(); } Data = new DataflowVisitor(); _sourceBlock = new BufferBlock <int>() .Hook("Buffer", Data, 10, 300, Colors.SteelBlue); _sourceBlock.AddCommand("Add Item", PostCommand); // TODO: know complete processing counter _block = new TransformBlock <int, string>(i => { ReflectBlockExtensions.ProcessItem(i, _sync, _block.BlockInfo); return(new string('*', i)); }, BLOCK_OPTIONS) .Hook("Transform", Data, 500, 10); _block.AddCommand("Release One", ReleaseSingleProcessingTaskCommand); var nullTarget = DataflowBlock.NullTarget <int>() .Hook("NullTarget", Data, 500, 500); _nullTarget = DataflowBlock.NullTarget <string>() .Hook("NullTarget", Data, 900, 200); _sourceBlock.LinkTo(_block, LINK_OPTIONS); _unlinkGarbage = _sourceBlock.LinkTo(nullTarget, LINK_OPTIONS); _block.LinkCandidate(_nullTarget, LINK_OPTIONS); //_toolbar.DataContext = this; }