Class WeakEventManager<T>.ListenerList
Provides a built-in collection list for storing listeners for a WeakEventManager.
Inheritance
Namespace: System.Windows
Assembly: Telerik.Windows.Controls.dll
Syntax
protected class ListenerList : Object
Constructors
ListenerList()
Initializes a new instance of the WeakEventManager.ListenerList class.
Declaration
public ListenerList()
ListenerList(Int32)
Initializes a new instance of the WeakEventManager.ListenerList class with the specified initial capacity.
Declaration
public ListenerList(int capacity)
Parameters
System.Int32
capacity
|
Properties
Count
Gets the number of items contained in the WeakEventManager.ListenerList.
Declaration
public int Count { get; }
Property Value
System.Int32
|
Empty
Gets a value that represents an empty list for purposes of comparisons.
Declaration
public static WeakEventManager<T>.ListenerList Empty { get; }
Property Value
WeakEventManager.ListenerList<>
|
IsEmpty
Gets a value that declares whether this WeakEventManager.ListenerList is empty.
Declaration
public bool IsEmpty { get; }
Property Value
System.Boolean
|
Item[Int32]
Gets a value that declares whether this WeakEventManager.ListenerList is empty.
Declaration
public IWeakEventListener this[int index] { get; }
Parameters
System.Int32
index
The zero-based index of the listener in the list. |
Property Value
IWeakEventListener
The item at that index, or a null reference if no item was at that index. |
Methods
Add(IWeakEventListener)
Adds a listener item to the WeakEventManager.ListenerList.
Declaration
public void Add(IWeakEventListener listener)
Parameters
IWeakEventListener
listener
The listener element to add to the WeakEventManager.ListenerList. |
BeginUse()
Declares the list to be in use. This prevents direct changes to the list during iterations of the list items.
Declaration
public bool BeginUse()
Returns
System.Boolean
true if the list was already declared to be in use; otherwise, false. |
Remarks
A WeakEventManager implementation should call BeginUse before iterating through the list to deliver an event to the listeners, and should call EndUse when it is done. This prevents another caller from modifying the list while the iteration for purposes of event delivery is in progress. If the list is modified during this time, then the list is cloned. If the list is cloned, then PrepareForWriting returns true, which means that you have missed a recent listener change in the last delivery.
Clone()
Creates a modifiable clone of this WeakEventManager.ListenerList.
Declaration
public WeakEventManager<T>.ListenerList Clone()
Returns
WeakEventManager.ListenerList<>
A modifiable clone of the current object. |
EndUse()
Unlocks the locked state initiated by BeginUse.
Declaration
public void EndUse()
PrepareForWriting(ref WeakEventManager<T>.ListenerList)
Checks to see whether the provided list is in use, and if so, sets the list reference parameter to a copy of that list rather than the original.
Declaration
public static bool PrepareForWriting(ref WeakEventManager<T>.ListenerList list)
Parameters
WeakEventManager.ListenerList<>
list
The list to check for use state and potentially copy. |
Returns
System.Boolean
true if the provided list was in use at the time of call and therefore the list parameter reference was reset to be a copy. false if the provided list was not in use, in which case the list parameter reference remains unaltered. |
Purge()
Removes all entries from the list where the underlying reference target is a null reference.
Declaration
public bool Purge()
Returns
System.Boolean
Returns true if any entries were purged; otherwise, false. |
Remove(IWeakEventListener)
Removes the first occurrence of a listener item from the WeakEventManager.ListenerList.
Declaration
public void Remove(IWeakEventListener listener)
Parameters
IWeakEventListener
listener
The item to remove. |