Editar

Compartilhar via


WeakEventManager<TEventSource,TEventArgs> Class

Definition

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.

generic <typename TEventSource, typename TEventArgs>
 where TEventArgs : EventArgspublic ref class WeakEventManager : System::Windows::WeakEventManager
public class WeakEventManager<TEventSource,TEventArgs> : System.Windows.WeakEventManager where TEventArgs : EventArgs
type WeakEventManager<'EventSource, 'EventArgs (requires 'EventArgs :> EventArgs)> = class
    inherit WeakEventManager
Public Class WeakEventManager(Of TEventSource, TEventArgs)
Inherits WeakEventManager

Type Parameters

TEventSource

The type that raises the event.

TEventArgs

The type that holds the event data.

Inheritance
WeakEventManager<TEventSource,TEventArgs>

Remarks

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.

Properties

Dispatcher

Gets the Dispatcher this DispatcherObject is associated with.

(Inherited from DispatcherObject)
Item[Object]

Gets or sets the data being stored for the specified source.

(Inherited from WeakEventManager)
ReadLock

Establishes a read-lock on the underlying data table, and returns an IDisposable.

(Inherited from WeakEventManager)
WriteLock

Establishes a write-lock on the underlying data table, and returns an IDisposable.

(Inherited from WeakEventManager)

Methods

AddHandler(TEventSource, String, EventHandler<TEventArgs>)

Adds the specified event handler to the specified event.

CheckAccess()

Determines whether the calling thread has access to this DispatcherObject.

(Inherited from DispatcherObject)
DeliverEvent(Object, EventArgs)

Delivers the event being managed to each listener.

(Inherited from WeakEventManager)
DeliverEventToList(Object, EventArgs, WeakEventManager+ListenerList)

Delivers the event being managed to each listener in the provided list.

(Inherited from WeakEventManager)
Equals(Object)

Determines whether the specified object is equal to the current object.

(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)
NewListenerList()

Returns a new object to contain listeners to an event.

ProtectedAddHandler(Object, Delegate)

Adds the specified delegate as an event handler of the specified source.

(Inherited from WeakEventManager)
ProtectedAddListener(Object, IWeakEventListener)

Adds the provided listener to the provided source for the event being managed.

(Inherited from WeakEventManager)
ProtectedRemoveHandler(Object, Delegate)

Removes the previously added handler from the specified source.

(Inherited from WeakEventManager)
ProtectedRemoveListener(Object, IWeakEventListener)

Removes a previously added listener from the provided source.

(Inherited from WeakEventManager)
Purge(Object, Object, Boolean)

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)
Remove(Object)

Removes all listeners for the specified source.

(Inherited from WeakEventManager)
RemoveHandler(TEventSource, String, EventHandler<TEventArgs>)

Removes the specified event handler from the specified event.

ScheduleCleanup()

Requests that a purge of unused entries in the underlying listener list be performed on a lower priority thread.

(Inherited from WeakEventManager)
StartListening(Object)

Starts listening for the event on the specified object.

StopListening(Object)

Stops listening for the event on the specified object.

ToString()

Returns a string that represents the current object.

(Inherited from Object)
VerifyAccess()

Enforces that the calling thread has access to this DispatcherObject.

(Inherited from DispatcherObject)

Applies to