9

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

I want to write a logger based on tlp dataflow.

I wrote this interface and want to delete a subscription for ILogListener when it needed.

public interface ILogManager
{
    void RemoveListener(ILogListener listener);
}
user45245
  • 845
  • 1
  • 8
  • 18

1 Answers1

14

When you link blocks:

var link = someSourceBlock.LinkTo(someTargetBlock);

you get a return value that implements IDisposable.

To kill the link, just dispose of that return value:

link.Dispose();

See the .LinkTo documentation (in particular the section about the return statement):

Return Value

Type: System.IDisposable

An IDisposable that, upon calling Dispose, will unlink the source from the target.

Community
  • 1
  • 1
spender
  • 117,338
  • 33
  • 229
  • 351