System.Runtime.Handles by Microsoft

<PackageReference Include="System.Runtime.Handles" Version="4.0.0-beta-22605" />

 SafeHandle

public abstract class SafeHandle : IDisposable
protected IntPtr handle

public bool IsClosed { get; }

public abstract bool IsInvalid { get; }

protected SafeHandle(IntPtr invalidHandleValue, bool ownsHandle)

public void DangerousAddRef(ref bool success)

public IntPtr DangerousGetHandle()

public void DangerousRelease()

public void Dispose()

protected virtual void Dispose(bool disposing)

protected abstract bool ReleaseHandle()

protected void SetHandle(IntPtr handle)

public void SetHandleAsInvalid()