EventHandlers and C# Classes destructor/Dispose

前端 未结 2 1103
渐次进展
渐次进展 2021-02-03 23:29

I\'m a bit confused about C# Classes and their deconstructor.

I have to consume a few event handlers in a class instance I\'m getting in the constructor:



        
2条回答
  •  我在风中等你
    2021-02-03 23:54

    If you ever face the problem of having class A be a long lived class and class(es) B be short lived ones that subscribe to events of class A then you probably would be interested in the Weak Event Pattern. It can be a problem that you do not discover is one until it is to late i.e. Princeton self driving car.

提交回复
热议问题