Confused about Finalizer....
Hi,
I have a class , WaveHdr. This class implements IDisposable. I also have a Finalizer for the class, ~WaveHdr. The Finalizer calls the Dispose method.
Also, withing the class there is a method called read. In this method I allocate, on the heap, an byte array as a local variable. The read method is called many, many times.
Here is what I am observing...
The finalizer for the class is called as many times as I have allocated the byte array in the read method. Also the finalizer is invoked before I am done with the class. It looks like the finalizer is called when the byte array (local variable in the read method) turns into garbage.
My question is , why does the finalizer for the CLASS get called when the bytes array turns into garbage? I was expecting that the finalizer for the CLASS would not be called until the class instance itself turned into garbage?
Would greatly appreciate some insight on this.
Thanks.