Weak |
public class WeakActionHandler<T1, T2>
The WeakActionHandlerT1, T2 type exposes the following members.
Name | Description | |
---|---|---|
WeakActionHandlerT1, T2(ActionT1, T2, Object, String) | Initializes a new instance of the WeakActionHandler class. | |
WeakActionHandlerT1, T2(ActionT1, T2, Type, String) | Initializes a new instance of the WeakActionHandler class for a static event. |
Name | Description | |
---|---|---|
EventSource | Gets the event source. Attention! Use the returned value only locally, otherwise, you will get a dependence that you wanted to avoid. |
Name | Description | |
---|---|---|
Equals | Determines whether the specified object is equal to the current object. (Inherited from Object) | |
EventSink | Handles the event from the original source. You must not call this method directly. However, it can be neccessary to use the method reference if the implicit casting fails. See remarks in the description of this class. | |
Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object) | |
GetHashCode | Serves as the default hash function. (Inherited from Object) | |
GetType | Gets the Type of the current instance. (Inherited from Object) | |
MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object) | |
Remove | Removes the event handler from the event source, using the stored remove action.. | |
ToString | Returns a string that represents the current object. (Inherited from Object) |
Name | Description | |
---|---|---|
(WeakActionHandlerT1, T2 to ActionT1, T2) | Converts this instance to an action that can be used to add or remove it from/to an event. |
source.ActionEvent += new WeakActionHandler<MyArg1,MyArg2>(this.EhActionHandling, x => source.ActionEvent -= x);
source.ActionEvent += new WeakActionHandler<MyArg1,MyArg2>(this.EhActionHandling, x=> source.ActionEvent -= x.EventSink).EventSink;
_weakActionHandler = new WeakActionHandler<MyArg1,MyArg2>(this.EhActionHandling, x => source.ActionEvent -= x); // _weakActionHandler is an instance variable of this class source.ActionEvent += _weakActionHandler; . . . source.ActionEvent -= _weakActionHandler;