.NET object events and dispose / GC

后端 未结 7 2069
孤城傲影
孤城傲影 2020-12-09 12:28

EDIT: After Joel Coehoorns excellent answer, I understand that I need to be more specific, so I modified my code to be closer to thing I\'m trying to unders

7条回答
  •  遥遥无期
    2020-12-09 13:30

    I would have my class B implements IDisposable as well and in it's dispose routine, I would first check whether A is not null and then dispose A. By using this approach you have to just make sure to dispose the last of your class and the internals will handle all other dispose.

提交回复
热议问题