2 ms·
Nothing public unfortunately. It's pretty straightforward though. Just declare a delegate with the same type signature as a your C function callback. Add that
by vvanders 9y ago
Nothing public unfortunately.
It's pretty straightforward though. Just declare a delegate with the same type signature as a your C function callback. Add that as the signature passed in to a native function and C# will make sure to marshal it to a standard C function pointer.
Only catch is if you want to keep a hold of the pointer in native you need to make sure to create a GCHandle to the passed in delegate with an identical lifetime. Otherwise the GC will collect the delegate from underneath you.