Class WeakEventListener<TInstance, TSource, TEventArgs>
Implements a weak event listener that allows the owner to be garbage collected if its only remaining link is an event handler.
Inheritance
System.Object
WeakEventListener<TInstance, TSource, TEventArgs>
Namespace: ISynergy.Framework.Core.Events
Assembly: ISynergy.Framework.Core.dll
Syntax
public sealed class WeakEventListener<TInstance, TSource, TEventArgs> : object where TInstance : class
Type Parameters
Name | Description |
---|---|
TInstance | Type of instance listening for the event. |
TSource | Type of source for the event. |
TEventArgs | Type of event arguments for the event. |
Constructors
View SourceWeakEventListener(TInstance)
Initializes a new instance of the WeakEventListener<TInstance, TSource, TEventArgs> class.
Declaration
public WeakEventListener(TInstance instance)
Parameters
Type | Name | Description |
---|---|---|
TInstance | instance | Instance subscribing to the event. |
Properties
View SourceOnDetachAction
Gets or sets the method to call when detaching from the event.
Declaration
public Action<WeakEventListener<TInstance, TSource, TEventArgs>> OnDetachAction { get; set; }
Property Value
Type | Description |
---|---|
Action<WeakEventListener<TInstance, TSource, TEventArgs>> |
OnEventAction
Gets or sets the method to call when the event fires.
Declaration
public Action<TInstance, TSource, TEventArgs> OnEventAction { get; set; }
Property Value
Type | Description |
---|---|
Action<TInstance, TSource, TEventArgs> |
Methods
View SourceDetach()
Detaches from the subscribed event.
Declaration
public void Detach()
OnEvent(TSource, TEventArgs)
Handler for the subscribed event calls OnEventAction to handle it.
Declaration
public void OnEvent(TSource source, TEventArgs eventArgs)
Parameters
Type | Name | Description |
---|---|---|
TSource | source | Event source. |
TEventArgs | eventArgs | Event arguments. |