SafeHandle with other handles than IntPtr #44456
-
I'm using SafeHandles in my pinvokes for CUDA API calls. I have created many SafeHandles that work pretty well since most of the API calls work with IntPtr for which purpose the SafeHandle was made for. Now I'm encountering pinvoke signatures. As an example:
where
I wanted to use a derived SafeHandle but since the handle is in the end an int I have no idea how to put it in there if it's even possible. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
(Hope that I understood the problem), but beginning with C# 9 you can use |
Beta Was this translation helpful? Give feedback.
-
I think the marshaling code for |
Beta Was this translation helpful? Give feedback.
I think the marshaling code for
SafeHandle
assumes pointer-sized handles, unfortunately. Given that, I'm not actually sure what our recommendation is for a fixed-sized handle - it might be possible to replicateSafeHandle
functionality from only managed code but that seems fairly high-effort. @AaronRobinsonMSFT do you know?