How to move / copy data from MFC to C ++ / CLI using events / delegates / callback

We have an MFC application setup where the client receives data from the server whenever new data is available. The client is being rewritten in C #, but the connection to the server part is in MFC. We have written a C ++ / CLI wrapper for classes related to MFC, and we can receive application initialization data. The communication mechanism is still in MFC, and we created wrapper classes for data items only. When we initialize the CLI wrapper, we copy the data from the MFC arrays to the CLI arrays. But I'm not sure how to get the data, say, after 5 seconds. How can he notify the C ++ / CLI wrapper that new data was received by MFC code running in the background. Please let me know if you need clarification. Thank.

or Is there a way to call the C ++ / CLI method from C ++ code?

Note: its compilation in mixed mode, which has vC ++ and C ++ / CLI code.

Edit ::

As mentioned by Hans below, a query has been added for callback solutions.

0
source share
1 answer

This issue was resolved by converting CPP events to CLI delegates that are recognized by .NET as .NET delegates.

this way we can control actions in C # end from CPP. If anyone has a better solution, please share.

0
source

Source: https://habr.com/ru/post/1792824/


All Articles