TPL Dataflow, how to remove a link between blocks

I'd like to know. How to remove a link between blocks? In other words. I want to get the opposite of LinkTo.

I want to write a log based on tlp data stream.

I wrote this interface and want to remove the subscription for ILogListener when necessary.

public interface ILogManager { void RemoveListener(ILogListener listener); } 
+6
source share
1 answer

When you link the blocks:

 var link = someSourceBlock.LinkTo(someTargetBlock); 

you will get a return value that implements IDisposable .

To kill a link, simply remove this return value:

 link.Dispose(); 

See the .LinkTo documentation (specifically the return statement section):

Return value

Type: System.IDisposable

An identifier that, after calling Dispose, will disconnect the source from the target.

+7
source

Source: https://habr.com/ru/post/971915/


All Articles