Added SafeHANDLE.ReleaseOwnership method to extract handle from safe handle so it is not closed on disposal.

pull/250/head
dahall 2021-06-03 19:52:26 -06:00
parent 4bfb89c728
commit 20bdf64790
1 changed files with 9 additions and 0 deletions

View File

@ -2258,6 +2258,15 @@ namespace Vanara.PInvoke
/// <returns>A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.</returns>
public override int GetHashCode() => base.GetHashCode();
/// <summary>Releases the ownership of the underlying handle and returns the current handle.</summary>
/// <returns>The value of the current handle.</returns>
public IntPtr ReleaseOwnership()
{
var ret = handle;
SetHandleAsInvalid();
return ret;
}
/// <summary>
/// Internal method that actually releases the handle. This is called by <see cref="ReleaseHandle"/> for valid handles and afterwards
/// zeros the handle.