VB.Net by API/System/WeakReference — различия между версиями

Материал из VB Эксперт
Перейти к: навигация, поиск
м (1 версия)
 
(нет различий)

Текущая версия на 12:50, 26 мая 2010

New WeakReference

   

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