Displaying 1 result from an estimated 1 matches for "methodwithcallback".
2014 Nov 29
3
[LLVMdev] Frontend: How to use Member to Function Pointer as callbacks
...n void mempcy(void* dest, void* src, int size);
// declaration of C function
memcpy(ptr1, ptr2, 32); // let's use it in C# code
That's quite easy to support.
However, the tricky part is that C# functions pointers (callbacks, a.k.a
delegate) can be transmitted to those C functions:
C:
void MethodWithCallback(void(*callback)(int));
C#:
delegate void CallbackType(int result); // <-- Point to a member to
function pointer (need "this")
[DllImport("mylib.so")] extern void MethodWithCallback(CallbackType
callback);
An extra "this" parameter is needed to call the real method...