Early Preview

This is currently very much a preview. Please feel free to try things out, but don't be upset if anything is not yet working. Feedback is welcome over on our GitHub Dicussions page.

struct System.​Runtime.​DependentHandle

Assembly: System.Runtime

Represents a dependent garbage-collection handle. The handle will conditionally keep a dependent object instance alive as long as a target object instance is alive as well, without representing a strong reference to the target instance.

Properties

public object
Dependent
Gets or sets the dependent object instance for the current handle.
public bool
IsAllocated
Gets a value indicating whether this instance was constructed with <see cref="M:System.Runtime.DependentHandle.#ctor(System.Object,System.Object)" /> and has not yet been disposed.
public object
Target
Gets or sets the target object instance for the current handle. The target can only be set to a <see langword="null" /> value once the <see cref="T:System.Runtime.DependentHandle" /> instance has been created. Doing so will cause <see cref="P:System.Runtime.DependentHandle.Dependent" /> to start returning <see langword="null" /> as well, and to become eligible for collection even if the previous target is still alive.
public ValueTuple`2
TargetAndDependent
Gets the values of both <see cref="P:System.Runtime.DependentHandle.Target" /> and <see cref="P:System.Runtime.DependentHandle.Dependent" /> (if available) as an atomic operation. That is, even if <see cref="P:System.Runtime.DependentHandle.Target" /> is concurrently set to <see langword="null" /> , calling this method will either return <see langword="null" /> for both target and dependent, or return both previous values. If <see cref="P:System.Runtime.DependentHandle.Target" /> and <see cref="P:System.Runtime.DependentHandle.Dependent" /> were used sequentially in this scenario instead, it would be possible to sometimes successfully retrieve the previous target, but then fail to get the dependent.

Methods

public void
Dispose​()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public bool
Equals​(object obj)
Inherited from ValueType
obj The object to compare with the current instance.
Returns <see langword="true" /> if <paramref name="obj" /> and this instance are the same type and represent the same value; otherwise, <see langword="false" /> .
Indicates whether this instance and a specified object are equal.
public int
GetHashCode​()
Inherited from ValueType
Returns A 32-bit signed integer that is the hash code for this instance.
Returns the hash code for this instance.
public string
ToString​()
Inherited from ValueType
Returns The fully qualified type name.
Returns the fully qualified type name of this instance.
protected void
Finalize​()
Inherited from object
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
public Type
GetType​()
Inherited from object
Returns The exact runtime type of the current instance.
Gets the <see cref="T:System.Type" /> of the current instance.
protected object
MemberwiseClone​()
Inherited from object
Returns A shallow copy of the current <see cref="T:System.Object" /> .
Creates a shallow copy of the current <see cref="T:System.Object" /> .