public class Test
public Shared Sub Main
Dim wr As WeakReference
Dim obj As New Person()
wr = New WeakReference(obj)
End Sub
End class
Public Class Person
Implements IDisposable
Private Disposed As Boolean = False
Public Overloads Sub Dispose() Implements IDisposable.Dispose
Dispose(True)
System.GC.SuppressFinalize(Me)
End Sub
Protected Overloads Sub Dispose(ByVal disposing As Boolean)
Me.Disposed = True
End Sub
Protected Overrides Sub finalize()
Console.WriteLine("In Person Finalize")
MyBase.Finalize()
Me.Dispose(False)
End Sub
End Class
|