Asynchronous communication between C ++ and C # in one application

Is there a way by which I can asynchronously communicate with C # code from C ++ in the same process?

I mean, I need to mix managed C # and unmanaged C ++ (using pInvoke) in the same WindowsCE based application. The C # part is the core of the application. The C ++ component has a thread that listens for events when the event is intercepted. I want to have a way to communicate with part of C # when the event was triggered.

At the moment, I thought events were a way of communicating between C ++ and C #, but is this possible?

Is there any way to make this message asynchronously?

thanks,

+4
source share
2 answers

Communication asynchronously between C # and C ++ is no different from asynchronous communication between two parts of a C # application - you just end up calling another function at the end, that is, the C # delegate types turn into function pointers in C ++ ending with .NET courtesy Jit. This is called P / Invoke inverse and allows unmanaged C ++ to invoke .NET code.

+1
source

The usual approach is to use callbacks that are represented as delegates in managed code and as pointers to functions in unmanaged code. Here's an MSDN article that outlines the approach:

How to pass delegate ^ to the main function waiting for the function pointer

0
source

All Articles