Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

WeakSubscriber.Create<TOwner, TEventArgs, THandler>(TOwner, Action<TOwner, Object, TEventArgs>, Action<IWeakSubscriber<THandler>, Object>, Func<WeakSubscriber.IHandler<TEventArgs>, THandler>) Method

Creates an event handler that prevents memory leaks caused by strong references between event publishers and subscribers.

Namespace: DevExpress.Maui.Mvvm

Assembly: DevExpress.Maui.Mvvm.dll

NuGet Package: DevExpress.Maui.Mvvm

#Declaration

C#
public static IWeakSubscriber<THandler> Create<TOwner, TEventArgs, THandler>(
    TOwner eventHandlerOwner,
    Action<TOwner, object, TEventArgs> eventHandler,
    Action<IWeakSubscriber<THandler>, object> unsubscribe,
    Func<WeakSubscriber.IHandler<TEventArgs>, THandler> createHandler
)
    where TOwner : class

#Parameters

Name Type Description
eventHandlerOwner TOwner

The class instance that handles the specified event.

eventHandler Action<TOwner, System.Object, TEventArgs>

An action that invokes when the event occurs.

unsubscribe Action<IWeakSubscriber<THandler>, System.Object>

An action that unsubscribes from the specified event.

createHandler Func<WeakSubscriber.IHandler<TEventArgs>, THandler>

The function that returns the actual event handler. It is always should be: x => x.OnEvent

#Type Parameters

Name Description
TOwner

The type of class that handles an event.

TEventArgs

The type of event arguments associated with the event.

THandler

The event handler type.

#Returns

Type Description
IWeakSubscriber<THandler>

An object that provides the event handler to make an event subscription.

See Also