c# - 将 boost::signal 包装到 C# 委托(delegate)

标签 c# c++ boost wrapper swig

假设我有一个异步库,用 native C++ 编写,具有与此类似的接口(interface):

class connection {
public:
    boost::signal< void() > sig_connection_made;
    boost::signal< void(const std::string&) > sig_error;

    void connect(const std::string& host, const std::string& port);
};

我想用 C# 包装。有谁知道使用 SWIG 或类似东西的方法可以让我将信号绑定(bind)到 C# 委托(delegate)?

最佳答案

您可以使用 SWIG 将委托(delegate)从 C# 传递到 C++,将其分配给函数指针,然后调用函数指针,它将触发委托(delegate)。

关于c# - 将 boost::signal 包装到 C# 委托(delegate),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/295533/

相关文章:

c# - 如何在 C# 中比较 2 个 DateTime

c++ - 简单的线程计时器,请进行健全性检查

c++ - boost IPC Message_Queue try_receive 抛出 interprocess_exception::library_error

c++ - 带 boost 的最小生成树

c++ - 为 python/c++ 初学者有效编写软件的资源/书籍建议

serialization - boost.serialization 的输出格式是什么

c# - Exchange server 2010 版本支持对 asp.net 的文件夹搜索

c# - 在 C# 中从快照恢复 SQL Server 数据库

c# - Entity Framework 6 DbUpdateConcurrencyException 将新行添加到数据库时

python - Quantlib 1.14 和 Quantlib1.14-SWIG : versions of Visual C++ prior to VC++10 (2010) are no longer supported