Skip to content

WeakEventListener usage holds strong reference #56

@jianchun

Description

@jianchun

Suspect the usage of WeakEventListener is incorrect. E.g.,

var weakEvent = new WeakEventListener<AdaptiveTrigger, CoreWindow,
                                     WindowSizeChangedEventArgs>(this)
{
    OnEventAction = (instance, s, e) => OnCoreWindowOnSizeChanged(s, e),
    ...
};

private void OnCoreWindowOnSizeChanged(CoreWindow sender, WindowSizeChangedEventArgs args)
{

OnEventAction is assigned an lambda. The lambda captures this (implicitly as this.OnCoreWindowOnSizeChanged). Thus weakEvent holds a strong reference to event target this.

Thanks for this inspiring project!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions