Using IDisposable to unsubscribe events

前端 未结 9 2134
广开言路
广开言路 2020-11-28 05:52

I have a class that handles events from a WinForms control. Based on what the user is doing, I am deferencing one instance of the class and creating a new one to handle the

9条回答
  •  猫巷女王i
    2020-11-28 06:47

    Another option would be to use weak delegates or something like WPFs weak events, instead of having to unsubscribe explicitly.

    P.S. [OT] I consider the decision to only provide strong delegates the single most expensive design mistake of the .NET platform.

提交回复
热议问题