Use the delegate so that unmanaged code invokes the managed method. Marshall :: GetFunctionPointerForDelegate () creates a stub that takes care of the transition, an instance method is supported. You can apply the return pointer to a function pointer that can be used by unmanaged code.
You will find the full sample code in this answer .
source share