Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

Memory management for events and event handlers

$
0
0

Hi Everyone,

I have searched and read up on this topic and I gather that when you assign event handlers, you must release these. So if you have something like : MyViewController.SomeEvent += HandleEvent; in ViewDidLoad, you should release this in ViewDidDisappear by doing something like MyViewController.SomeEvent -= HandleEvent

My question is, do you need to do this with anonymous methods as well? One I have a lot of are button events.

Button.TouchUpInside += (obj, eventargs) => {
 //Do something here
}

Do I need to release this somehow? And if so, how do I do this?

Cheers!


Viewing all articles
Browse latest Browse all 204402

Trending Articles



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