Work with Signals
What you should know beforehand:
Examples (?):
SolutionStateTracker.cs - more complex example of using signals
Signal is a way for a class to provide notifications. Signals are very similar to C# events, nevertheless, there are differences that make them more suitable for use within ReSharper data flow infrastructure.
Notes
Signals must implement the
ISignal
interface.To "subscribe" a handler to a signal, use the
Advise
method. A signal allows any number of listeners.Unlike C# events, you should not care about "unsubscribing" from a signal to prevent memory leak. When you "subscribe" to a signal via
Advise
, you also pass a lifetime. Once the lifetime is terminated, ReSharper will take care about "unsubscribing" by itself.To fire the signal, use the
Fire
method.Signals have much in common with IProperty.
Signals are perfectly suited for MVC concept when an event should be fired by a view.
In simple cases, when you need a signal only for notification purposes (with no payload), you can use the
ISimpleSignal
interface.