Hey Ben,
Thanks for the response. I am using the
Marshal.GetFunctionPointerForDelegate, but had read that it returns just a
regular pointer, not a pinned pointer. Do I still need to use GCHandle? Or
will GetFunctionPointerForDelegate pinn it for me?
Thanks!
Turbo
> GCHandle is how you pin _data_ past function exit.
>
> In your case, you need to be using Marshal.GetFunctionPointerForDelegate
> instead.
Ben Voigt [C++ MVP] - 22 Oct 2007 14:14 GMT
> Hey Ben,
> Thanks for the response. I am using the
> Marshal.GetFunctionPointerForDelegate, but had read that it returns just a
> regular pointer, not a pinned pointer. Do I still need to use GCHandle?
> Or
> will GetFunctionPointerForDelegate pinn it for me?
The docs explain that you still need to keep the delegate alive with a
managed reference... however as nearly as I can tell the native function
pointer doesn't need to be pinned in any way.
Hope this helps.
> Thanks!
>
[quoted text clipped - 4 lines]
>> In your case, you need to be using Marshal.GetFunctionPointerForDelegate
>> instead.