R
R
Roman Rakzin2015-11-22 19:23:33
C++ / C#
Roman Rakzin, 2015-11-22 19:23:33

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

3 answer(s)
O
Oleg Tsilyurik, 2015-11-22
@Olej

how to write a library in C++ and then include it in a C# project

;-)
It is impossible to harness a Donkey and a quivering doe into one cart .

M
Melz, 2015-11-23
@melz

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

A
Andryukha, 2015-11-23
@syrov

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 question

Ask a Question

731 491 924 answers to any question