I need to run an unmanaged C++ application, this application must be connected to a library in C# (dll which when loading must show a form with a button) and wait for form close event to terminate.
While the form is loaded, at the moment of pressing the button the click event should be executed, which should execute a function that can send a number of return to the console application in C ++ and this application will show the resulting number in the output of the console.
What I need is to solve point 5. shown below, I read a lot of documents but almost all refer to the interoperation between a C++ dll and a C# application and not the reverse (Return an integer value from C# dll to a C++ console application) is what is needed here.
The execution must be dynamic, that is, while the form is displayed, a communication should be established from a function of the C# library and a function of the parent C++ console application.
All the examples that I have been able to find do almost the same, load the libraries, establish the communication and, from the C++ console application they call a function of the C# library and show the resulting return value and the application ends, but no example shows how to load the C# library, show the form, press a button, and send a integer number as a result to the C++ parent console application and show the result in the output of the console.
If you have any idea how to implement the Callback, I would be very grateful.
What I have tried:
What has been achieved is:
1. Load C++ console application (unmanaged), achieved
2. Load a C# library from the C++ console application, achieved
3. Import and communicate with some functions exported from the C# library, achieved
4. When loading the C# library, from this library a form with an button is shown, achieved
5. While the form is displayed, press the button and execute a function in C# that returns an integer to the C++ console application and print the result in the output of the console from the C++ console application, pending