Early Preview

This is currently very much a preview. Please feel free to try things out, but don't be upset if anything is not yet working. Feedback is welcome over on our GitHub Dicussions page.

class Microsoft.​Win32.​SafeHandles.​SafeFileHandle

Assembly: System.Runtime

Inheritance: object → System.​Runtime.​ConstrainedExecution.​CriticalFinalizerObjectSystem.​Runtime.​InteropServices.​SafeHandleSafeHandleZeroOrMinusOneIsInvalid → SafeFileHandle

Implemented Interfaces

Represents a wrapper class for a file handle.

Fields and Constants

protected nint
handle
Specifies the handle to be wrapped.

Properties

public bool
IsInvalid
Gets a value that indicates whether the handle is invalid.
public bool
IsAsync
Gets a value that determines if the handle is asynchronous or not.
public bool
IsClosed
Gets a value indicating whether the handle is closed.

Methods

protected bool
ReleaseHandle​()
public void
Close​()
Marks the handle for releasing and freeing resources.
public void
DangerousAddRef​(System.​Boolean& success)
public nint
DangerousGetHandle​()
Returns the value of the <see cref="F:System.Runtime.InteropServices.SafeHandle.handle" /> field.
Returns An <see cref="T:System.IntPtr" /> representing the value of the <see cref="F:System.Runtime.InteropServices.SafeHandle.handle" /> field. If the handle has been marked invalid with <see cref="M:System.Runtime.InteropServices.SafeHandle.SetHandleAsInvalid" /> , this method still returns the original handle value, which can be a stale value.
public void
DangerousRelease​()
Manually decrements the reference counter on a <see cref="T:System.Runtime.InteropServices.SafeHandle" /> instance.
public void
Dispose​()
Releases all resources used by the <see cref="T:System.Runtime.InteropServices.SafeHandle" /> class.
protected void
Dispose​(bool disposing)
Releases the unmanaged resources used by the <see cref="T:System.Runtime.InteropServices.SafeHandle" /> class specifying whether to perform a normal dispose operation.
disposing <see langword="true" /> for a normal dispose operation; <see langword="false" /> to finalize the handle.
protected void
Finalize​()
Frees all resources associated with the handle.
protected void
SetHandle​(nint handle)
Sets the handle to the specified pre-existing handle.
handle The pre-existing handle to use.
public void
SetHandleAsInvalid​()
Marks a handle as no longer used.
public bool
Equals​(object obj)
Inherited from object
Determines whether the specified object is equal to the current object.
Returns <see langword="true" /> if the specified object is equal to the current object; otherwise, <see langword="false" /> .
obj The object to compare with the current object.
public int
GetHashCode​()
Inherited from object
Serves as the default hash function.
Returns A hash code for the current object.
GetType​()
Inherited from object
Gets the <see cref="T:System.Type" /> of the current instance.
Returns The exact runtime type of the current instance.
protected object
MemberwiseClone​()
Inherited from object
Creates a shallow copy of the current <see cref="T:System.Object" /> .
Returns A shallow copy of the current <see cref="T:System.Object" /> .
public string
ToString​()
Inherited from object
Returns a string that represents the current object.
Returns A string that represents the current object.