I am working to a VB.NET windows forms projet in .NET 1.1. And I have this type of architecture, very simplified.
Public MustInherit Class BaseTestLogic
Private _TimerPoll As Timer
Public Sub New(ByVal sym As SymbolFileMng, ByVal cfg As LampTestConfig, ByVal daas As DaasManager, ByVal mcf As Elux.Wg.Lpd.MCFs.VMCF)
AddHandler _TimerPoll.Tick, AddressOf TimerPoll_Tick
End Sub
End Class
Public Class SpecificTestLogic
Inherits BaseTestLogic
End Class
Depending of the type of test I am doing I create an instance of a specific test derived from BaseTestLogic. But I found that after hundreds of object creations I can have StackOverflow exception.
I checked my code and saw that I forgot to remove the handler to Timer Tick. The question is, where and when is it correct to remove hadler?
Do I need to implement the IDisposable interface in the base class and RemoveHandler in Dispose?