C++ backend with C# frontend?

后端 未结 5 786
天涯浪人
天涯浪人 2021-02-08 07:45

I have a project in which I\'ll have to process 100s if not 1000s of messages a second and process/plot this data on graphs accordingly (The user will search for a set of data i

5条回答
  •  故里飘歌
    2021-02-08 08:19

    If you have C/C++ source, consider linking it into C++/CLI .NET Assembly. This kind of project allows you to mix unmanaged code and put managed interfaces on it. The result is a simple .NET Assembly which is trivial to use in C# or VB.NET projects.

    There is built in marshaling of simple types, so that you can call functions from the managed C++ side into the unmanaged side.

    The only thing you need to be aware of is that when you marshall a delegate into a function pointer, that it doesn't hold a reference, so if you need the C++ to hold managed callbacks, you need to arrange for a reference to be held. Other than that, most of the built-in conversions work as expected. Visual studio will even let you debug across the boundary (turn on unmanaged debugging).

    If you have a .lib, you can use it in a C++/CLI project as long as it's linked to the C-Runtime dynamically.

提交回复
热议问题