WeakReference Constructor (Object, Boolean)

 

Initializes a new instance of the WeakReference class, referencing the specified object and using the specified resurrection tracking.

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

Public Sub New (
	target As Object,
	trackResurrection As Boolean
)

Parameters

target
Type: System.Object

An object to track.

trackResurrection
Type: System.Boolean

Indicates when to stop tracking the object. If true, the object is tracked after finalization; if false, the object is only tracked until finalization.

If trackResurrection is false, a short weak reference is created. If trackResurrection is true, a long weak reference is created.

The following example creates a cache of data objects with short weak references. This example is part of a larger example provided for the WeakReference class.

' Add data objects with a short weak reference to the cache. 
For ctr = 0 To count - 1
    _cache.Add(ctr, New WeakReference(New Data(ctr)))
Next

Universal Windows Platform
Available since 8
.NET Framework
Available since 1.1
Portable Class Library
Supported in: portable .NET platforms
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1
Return to top
Show: