Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 91519

Should I remove event handlers onDisappearing to reduce memory leaks?

$
0
0

I know that you should remove event handlers OnPause if you are on Android, but should you remove them OnDisappering in a xamarin forms app?

    private EventHandler<SelectedItemChangedEventArgs> _selectionHandler;

    public Sessionspage ()
    {
        InitializeComponent ();
        _selectionHandler += async (sender, e) => { await OnSelection(sender, e); };
    }

    protected override void OnAppearing ()
    {
        lstSessions.ItemSelected += _selectionHandler;
        base.OnAppearing ();
    }

    protected override void OnDisappearing ()
    {
        lstSessions.ItemSelected -= _selectionHandler;
        base.OnDisappearing ();
    }

Viewing all articles
Browse latest Browse all 91519

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>