WeakReference(Of T) Class

July 28, 2014

Represents a typed weak reference, which references an object while still allowing that object to be reclaimed by garbage collection.

System.Object
  System.WeakReference(Of T)

Namespace:  System
Assembly:  mscorlib (in mscorlib.dll)

'Declaration
Public NotInheritable Class WeakReference(Of T As Class)

Type Parameters

T

The type of the object referenced.

The WeakReference(Of T) type exposes the following members.

  NameDescription
Public methodWeakReference(Of T)(T)Initializes a new instance of the WeakReference(Of T) class that references the specified object.
Public methodWeakReference(Of T)(T, Boolean)Initializes a new instance of the WeakReference(Of T) class that references the specified object and uses the specified resurrection tracking.
Top

  NameDescription
Public methodEquals(Object)Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection. (Inherited from Object.)
Public methodGetHashCodeServes as a hash function for a particular type. (Inherited from Object.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodSetTargetSets the target object that is referenced by this WeakReference(Of T) object.
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Public methodTryGetTargetTries to retrieve the target object that is referenced by the current WeakReference(Of T) object.
Top

A weak reference allows the garbage collector to collect an object while still allowing an application to access the object. If you need the object, you can still obtain a strong reference to it and prevent it from being collected.

Windows Phone OS

Supported in: 8.1, 8.0

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Show:
© 2014 Microsoft