I am working on a VB.NET windows forms project in .NET 1.1. And I have this type of architecture is 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 on 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 creation, I might have a StackOverflow exception.
I checked my code and saw that I forgot to remove the handler in Timer Tick. The question is where and when to remove hadler correctly?
Do I need to implement the IDisposable interface in the base class and RemoveHandler in Dispose ?
Drake source share