mirror of https://github.com/dahall/Vanara.git
Added SafeHANDLE.ReleaseOwnership method to extract handle from safe handle so it is not closed on disposal.
parent
4bfb89c728
commit
20bdf64790
|
@ -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>
|
/// <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();
|
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>
|
/// <summary>
|
||||||
/// Internal method that actually releases the handle. This is called by <see cref="ReleaseHandle"/> for valid handles and afterwards
|
/// Internal method that actually releases the handle. This is called by <see cref="ReleaseHandle"/> for valid handles and afterwards
|
||||||
/// zeros the handle.
|
/// zeros the handle.
|
||||||
|
|
Loading…
Reference in New Issue