WeakReference.IsAlive WeakReference.IsAlive WeakReference.IsAlive WeakReference.IsAlive Property

定义

获取当前 WeakReference 对象引用的对象是否已被垃圾回收的指示。Gets an indication whether the object referenced by the current WeakReference object has been garbage collected.

public:
 virtual property bool IsAlive { bool get(); };
public virtual bool IsAlive { get; }
member this.IsAlive : bool
Public Overridable ReadOnly Property IsAlive As Boolean

属性值

如果当前 WeakReference 对象引用的对象尚未被垃圾回收且仍然可访问,则为 true;否则为 falsetrue if the object referenced by the current WeakReference object has not been garbage collected and is still accessible; otherwise, false.

注解

因为可能无法进行垃圾回收回收对象后立即IsAlive属性返回true,除非仅用于测试,否则不建议使用此属性false返回值。Because an object could potentially be reclaimed for garbage collection immediately after the IsAlive property returns true, using this property is not recommended unless you are testing only for a false return value.

适用于

另请参阅