Click or drag to resize

WeakEventListenerTTarget, TSource, TEventArgs Class

Implements a weak event listener that allows the owner to be garbage collected if its only remaining link is an event handler.
Inheritance Hierarchy
SystemObject
  TomsToolbox.CoreWeakEventListenerTTarget, TSource, TEventArgs

Namespace:  TomsToolbox.Core
Assembly:  TomsToolbox.Core (in TomsToolbox.Core.dll) Version: 1.0.68.0
Syntax
public class WeakEventListener<TTarget, TSource, TEventArgs> : IWeakEventListener
where TTarget : class
where TSource : class

Type Parameters

TTarget
Type of the target instance listening for the event.
TSource
Type of source instance for the event.
TEventArgs
Type of event arguments for the event.

The WeakEventListenerTTarget, TSource, TEventArgs type exposes the following members.

Constructors
  NameDescription
Public methodWeakEventListenerTTarget, TSource, TEventArgs(TTarget, WeakReferenceTSource, ActionTTarget, Object, TEventArgs, ActionWeakEventListenerTTarget, TSource, TEventArgs, TSource, ActionWeakEventListenerTTarget, TSource, TEventArgs, TSource)
Initializes a new instances of the WeakEventListener class that does not reference both source and target.
Public methodWeakEventListenerTTarget, TSource, TEventArgs(TTarget, TSource, ActionTTarget, Object, TEventArgs, ActionWeakEventListenerTTarget, TSource, TEventArgs, TSource, ActionWeakEventListenerTTarget, TSource, TEventArgs, TSource)
Initializes a new instances of the WeakEventListener class that references the source but not the target.
Top
Methods
  NameDescription
Public methodDetach
Detaches from the subscribed event.
Public methodOnEvent
Handler for the subscribed event calls OnEventAction to handle it.
Top
Extension Methods
  NameDescription
Public Extension MethodSafeCastT
Performs a cast from object to T, avoiding possible null violations if T is a value type.

[CanBeNull]

(Defined by ObjectExtensions.)
Top
See Also