Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion xml/System.Runtime.InteropServices/SafeHandle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ Optionally specify `-Fault` to intentionally attempt to leak the handle by abort
]]></format>
</example>
<block subset="none" type="overrides">
<para>To create a class derived from <see cref="T:System.Runtime.InteropServices.SafeHandle" />, you must know how to create and free an operating system handle. This process is different for different handle types because some use the [CloseHandle](/windows/win32/api/handleapi/nf-handleapi-closehandle) function, while others use more specific functions such as [UnmapViewOfFile](/windows/win32/api/memoryapi/nf-memoryapi-unmapviewoffile) or [FindClose](/windows/win32/api/fileapi/nf-fileapi-findclose). For this reason, you must create a derived class of <see cref="T:System.Runtime.InteropServices.SafeHandle" /> for each operating system handle type that you want to wrap in a safe handle.</para>
<para>To create a class derived from <see cref="T:System.Runtime.InteropServices.SafeHandle" />, you must know how to create and free an operating system handle. This process is different for different handle types because some use the <see href="/windows/win32/api/handleapi/nf-handleapi-closehandle">CloseHandle</see> function, while others use more specific functions such as <see href="/windows/win32/api/memoryapi/nf-memoryapi-unmapviewoffile">UnmapViewOfFile</see> or <see href="/windows/win32/api/fileapi/nf-fileapi-findclose">FindClose</see>. For this reason, you must create a derived class of <see cref="T:System.Runtime.InteropServices.SafeHandle" /> for each operating system handle type that you want to wrap in a safe handle.</para>
<para>When you inherit from <see cref="T:System.Runtime.InteropServices.SafeHandle" />, you must override the following members: <see cref="P:System.Runtime.InteropServices.SafeHandle.IsInvalid" /> and <see cref="M:System.Runtime.InteropServices.SafeHandle.ReleaseHandle" />.</para>
<para>You should also provide a public parameterless constructor that calls the base constructor with a value that represents an invalid handle value, and a <see cref="T:System.Boolean" /> value indicating whether the native handle is owned by the <see cref="T:System.Runtime.InteropServices.SafeHandle" /> and consequently should be freed when that <see cref="T:System.Runtime.InteropServices.SafeHandle" /> has been disposed.</para>
</block>
Expand Down