Skip to content

Implement IHandle and add associated overloads to methods accepting IntPtr #602

Open
@elachlan

Description

@elachlan

Is your feature request related to a problem? Please describe.
In winforms, an IHandle is used to provide "abstract access to classes that contain a potentially owned handle."
https://github.com/dotnet/winforms/blob/91f3f2395f156265bdd8f2d8e78361f786015cf8/src/System.Windows.Forms.Primitives/src/Interop/IHandle.cs#L1-L24

I am looking at converting Winforms to use CsWin32, and stumbled into usages that make use of IHandle. They are used to wrap the pinvoke call and then call GC.KeepAlive on the IHandle.

https://github.com/dotnet/winforms/blob/91f3f2395f156265bdd8f2d8e78361f786015cf8/src/System.Windows.Forms.Primitives/src/Interop/User32/Interop.ValidateRect.cs#L1-L21

Should an overload be provided by CsWin32 that provides this functionality? Does it already do so? Or should I keep the wrapper and remove the PInvoke?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions