.net - Garbagecollection of eventhandlers -


I have a windows app app with a list of populated people with Windows objects. When a user chooses an account from an account, I keep the EventHindler responsible for updating the selected account transaction in that event, when the user is watching that there is a new user.

  Private zero listBoxie 1 sealed integrated index (Object Sender, EventArggs E) {var selected = ListBox 1. As the selected account; If (selected! = Null) {Update Transaction (selected); Select.OnNewTransaction + = (S, A) => UpdateTransactions (selected); }}  

Then my question is as follows; Does this phenomenon be settled automatically as soon as the user selects another account from the list and the selected account goes out of the scope? Or does it continue to work continuously, and then if the user selects the same account, then it is handed over to another handler so that one can make a memory leak?

It remains, so every time the user selects the same account, then it Is assigned.

  EventHandlerType handler = (S, A) = & gt; UpdateTransactions (selected); Select.OnNewTransaction + = Handler; // When you want to remove the handler (make sure that you have selected "store" handler somewhere) On Nutracection - = Handler;  

Comments

Popular posts from this blog

sql - dynamically varied number of conditions in the 'where' statement using LINQ -

asp.net mvc - Dynamically Generated Ajax.BeginForm -

Debug on symbian -