Is a spontaneous event being executed so that the instance is not garbage collected?

I read the answer to the question. Did event handlers stop collecting garbage collection? but what happens when the publisher is the target?

To be more specific, I am using an MVVM project for a WPF application. Model-View classes increment NotifyPropertyChanged with every change. In some classes, I need to call a method when something has changed.

I would like to do this:

this.PropertyChanged += this.MyHandler;

Will these GC instances be destroyed?

+3
source share
3 answers

GC , - . , , .

, , , : A B :

A.Event += B.Handler; 
B.Event += A.Handler;

A B , GC , , . , ( ) , .

GC . , .NET gc .

+8

, GC , , .

GC , ( , ..), , , , .. , " ". , , " ", .

, GC , , .

+2

, , GC , .

, , objectA B, objectB A , , GC , .

( - SO )

+1
source

Source: https://habr.com/ru/post/1708752/


All Articles