Class WeakDelegate
- Namespace
- nanoFramework.Runtime.Events
- Assembly
- nanoFramework.Runtime.Events.dll
Provides methods for combining and removing "weak" delegates.
public static class WeakDelegate
- Inheritance
-
WeakDelegate
- Inherited Members
Remarks
When instances of the WeakDelegate class are created, the object references in the delegate list are treated like WeakReference objects. This means that these object references are prone to garbage collection even if they are still targets in the list of delegates. When such object references are collected as garbage, they are automatically removed from the list of delegates.
Methods
Combine(Delegate, Delegate)
Concatenates the invocation lists of two multicast (combinable) delegates.
public static Delegate Combine(Delegate a, Delegate b)
Parameters
a
DelegateThe combinable delegate whose invocation list comes first.
b
DelegateThe combinable delegate whose invocation list comes second.
Returns
- Delegate
A new combinable delegate with an invocation list that concatenates the invocation lists of the a and b parameters, in that order. If b is a null reference, this method returns a. If a is a null reference, this method returns b. If both a and b are null references, this method returns null.
Remove(Delegate, Delegate)
Removes the invocation list of a specified delegate from the invocation list of another specified delegate.
public static Delegate Remove(Delegate a, Delegate b)
Parameters
a
DelegateThe delegate from which the invocation list is to be removed.
b
DelegateThe delegate that supplies the invocation list to be removed from the delegate specified in a.
Returns
- Delegate
A new delegate with an invocation list formed by taking the invocation list of the a parameter and removing the invocation list of the b parameter, if b's invocation list is found in a's invocation list. If b is a null reference, or if b's invocation list is not found in a's invocation list, this method returns a. If b's invocation list is equal to a's invocation list, or if b is a null reference, this method returns null.