Sudripta

Sudripta

  • NA
  • 1
  • 0

Passing function or interface pointers from C++ to C#

May 26 2010 7:12 AM
I have a C# dll and a C++ executable. I am using COM to communicate between the unmanaged and the managed layers using COM interop. Everything is fine except for one problem. I have one time consuming operation to be done within the C# dll. I need to notify the status of the operation (i.e. percentage complete) to the C++ executable. So, I have two options:

1. To use a C++ function pointer which I will pass to the C# dll from the C++ executable. The C# dll will save this function pointer using something like delegate etc., and will call the function to update the status whenever needed.

2. To use a interface pointer which I will pass to the C# dll. The C# dll will call some function of this interface.


But, I am unsure of how to do any one of the above. Any ideas?