This topic has not yet been rated - Rate this topic

WeakReference Class

April 12, 2014

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

System.Object
  System.WeakReference

Namespace:  System
Assembly:  mscorlib (in mscorlib.dll)
public class WeakReference

The WeakReference type exposes the following members.

  NameDescription
Protected methodWeakReference()Initializes a new instance of the WeakReference class. This constructor overload cannot be implemented in XAML-based applications.
Public methodWeakReference(Object)Initializes a new instance of the WeakReference class, referencing the specified object.
Public methodWeakReference(Object, Boolean)Initializes a new instance of the WeakReference class, referencing the specified object and using the specified resurrection tracking.
Top
  NameDescription
Public propertyIsAliveGets an indication whether the object referenced by the current WeakReference object has been garbage collected.
Public propertyTargetGets or sets the object (the target) referenced by the current WeakReference object.
Public propertyTrackResurrectionGets an indication whether the object referenced by the current WeakReference object is tracked after it is finalized.
Top
  NameDescription
Public methodEquals(Object)Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected methodFinalizeDiscards the reference to the target represented by the current WeakReference object. (Overrides Object.Finalize().)
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 methodToStringReturns a string that represents the current object. (Inherited from 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, 7.1, 7.0

Windows Phone

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

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.