0 out of 1 rated this helpful - Rate this topic

WeakEventManager<TEventSource, TEventArgs> Class

.NET Framework 4.5

[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]

Provides a type-safe WeakEventManager that enables you to specify the event handler to use for the "weak event listener" pattern. This class defines a type parameter for the source of the event and a type parameter for the event data that is used.

System.Object
  System.Windows.Threading.DispatcherObject
    System.Windows.WeakEventManager
      System.Windows.WeakEventManager<TEventSource, TEventArgs>

Namespace:  System.Windows
Assembly:  WindowsBase (in WindowsBase.dll)
public class WeakEventManager<TEventSource, TEventArgs> : WeakEventManager
where TEventArgs : EventArgs

Type Parameters

TEventSource

The type that raises the event.

TEventArgs

The type that holds the event data.

The WeakEventManager<TEventSource, TEventArgs> type exposes the following members.

  Name Description
Public property Dispatcher Gets the Dispatcher this DispatcherObject is associated with. (Inherited from DispatcherObject.)
Protected property Item Gets or sets the data being stored for the specified source. (Inherited from WeakEventManager.)
Protected property ReadLock Establishes a read-lock on the underlying data table, and returns an IDisposable. (Inherited from WeakEventManager.)
Protected property WriteLock Establishes a write-lock on the underlying data table, and returns anIDisposable. (Inherited from WeakEventManager.)
Top
  Name Description
Public method Static member AddHandler Adds the specified event handler to the specified event.
Public method CheckAccess Determines whether the calling thread has access to this DispatcherObject. (Inherited from DispatcherObject.)
Protected method DeliverEvent Delivers the event being managed to each listener. (Inherited from WeakEventManager.)
Protected method DeliverEventToList Delivers the event being managed to each listener in the provided list. (Inherited from WeakEventManager.)
Public method Equals(Object) Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected method Finalize Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public method GetHashCode Serves as a hash function for a particular type. (Inherited from Object.)
Public method GetType Gets the Type of the current instance. (Inherited from Object.)
Protected method MemberwiseClone Creates a shallow copy of the current Object. (Inherited from Object.)
Protected method NewListenerList Returns a new object to contain listeners to an event. (Overrides WeakEventManager.NewListenerList().)
Protected method ProtectedAddHandler Adds the specified delegate as an event handler of the specified source. (Inherited from WeakEventManager.)
Protected method ProtectedAddListener Adds the provided listener to the provided source for the event being managed. (Inherited from WeakEventManager.)
Protected method ProtectedRemoveHandler Removes the previously added handler from the specified source. (Inherited from WeakEventManager.)
Protected method ProtectedRemoveListener Removes a previously added listener from the provided source. (Inherited from WeakEventManager.)
Protected method Purge Removes inactive listener entries from the data list for the provided source. Returns true if some entries were actually removed from the list. (Inherited from WeakEventManager.)
Protected method Remove Removes all listeners for the specified source. (Inherited from WeakEventManager.)
Public method Static member RemoveHandler Removes the specified event handler from the specified event.
Protected method ScheduleCleanup Requests that a purge of unused entries in the underlying listener list be performed on a lower priority thread. (Inherited from WeakEventManager.)
Protected method StartListening Starts listening for the event on the specified object. (Overrides WeakEventManager.StartListening(Object).)
Protected method StopListening Stops listening for the event on the specified object. (Overrides WeakEventManager.StopListening(Object).)
Public method ToString Returns a string that represents the current object. (Inherited from Object.)
Public method VerifyAccess Enforces that the calling thread has access to this DispatcherObject. (Inherited from DispatcherObject.)
Top

The WeakEventManager class enables you to leverage the weak event listener pattern by specifying the event to subscribe to, the source of the event, and event handler. You can use WeakEventManager<TEventSource, TEventArgs> as an alternative to implementing the IWeakEventListener interface and using a specialized WeakEventManager. When you call AddHandler, the source must be of type TEventSource and the event handler you pass must have TEventArgs as its event data. This ensures that type checking occurs at compile time.

.NET Framework

Supported in: 4.5

Windows 8 Consumer Preview, Windows Server 8 Beta, Windows 7, Windows Server 2008 SP2, Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Did you find this helpful?
(1500 characters remaining)