<PackageReference Include="Nito.Disposables" Version="2.5.0" />

Nito.Disposables.IReferenceCountedDisposable<T>

public interface IReferenceCountedDisposable<T> : IDisposable where T : IDisposable
An instance that represents a reference count. All members are threadsafe.
bool IsDisposed { get; }

Whether this instance is disposed (finished disposing).

bool IsDisposeStarted { get; }

Whether this instance is currently disposing or has been disposed.

bool IsDisposing { get; }

Whether this instance is currently disposing, but not finished yet.

T Target { get; }

Gets the target object. Throws ObjectDisposedException if this instance is disposed.

Returns a new reference to this reference counted disposable, incrementing the reference counter. Throws ObjectDisposedException if this instance is disposed.

Adds a weak reference to this reference counted disposable. Throws ObjectDisposedException if this instance is disposed.