Hi,
Tried searching Google on this topic but not many came up. Basically I
have a C# GUI client that wants to receive 'notifications' from a worker DLL
(which is implemented in C++/CLI). So far, from C# I am able to call any
method directly in C++/CLI DLL. But I would like to have the C++/CLI invoke
some callback methods from within C# (some event notifications so that the
GUI updates its UI).
In the old days using C/C++, I could do this easily by passing a class
object ptr to the DLL and have it invoke callback methods declared in that
class. Can I do the same thing in .NET? Since there is no header file, I
don't know how to 'tell' the C++/CLI component which C# callback methods to
use. Thanks.
Sheng Jiang[MVP] - 03 Oct 2007 19:07 GMT
you can fire some events in C++/CLI and handle these events in C#

Signature
Sheng Jiang
Microsoft MVP in VC++
> Hi,
> Tried searching Google on this topic but not many came up. Basically I
[quoted text clipped - 8 lines]
> don't know how to 'tell' the C++/CLI component which C# callback methods to
> use. Thanks.
Nicholas Paldino [.NET/C# MVP] - 03 Oct 2007 19:09 GMT
John,
Basically, you would define a separate assembly where you define the
delegate that is used for the callback (or an interface, if you need a more
elaborate contract).
Then, you would reference the callback from the client and in your C++
code, and expose the a parameter type/property/field which would receive the
callback in the C++ code. Then, you can just execute the delegate when
needed (or the member on the interface, if that is the way you are going).

Signature
- Nicholas Paldino [.NET/C# MVP]
- mvp@spam.guard.caspershouse.com
> Hi,
> Tried searching Google on this topic but not many came up. Basically I
[quoted text clipped - 8 lines]
> don't know how to 'tell' the C++/CLI component which C# callback methods
> to use. Thanks.