Answer the question
In order to leave comments, you need to log in
How to subscribe to an event in a C++ library from a C# project?
Good evening. Tell me how to write a library in C ++ and then connect it to a C # project and bind to an event that occurs in it?
A simple example:
there is a function that every 10 seconds generates the output value "Hello".
The C# program must respond and as soon as an event is generated in the library, display its value, for example, alert.
How to do this?
Thanks
Answer the question
In order to leave comments, you need to log in
how to write a library in C++ and then include it in a C# project
You can try a delegate and a standard callback.
blogs.msdn.com/b/davidnotario/archive/2006/01/13/5...
Or dig towards COM/C++ CLI
Create an AutoResetEvent in C#, pass SafeHandle. DangerousGetHandle in C++. Now wait in C# with WaitOne (various options) and call SetEvent in C++. And yet, incorrectly, you need a second event in the opposite direction that C# has finished processing the previous event.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question