如何将C#委托连接到boost :: signal

问题描述

我尝试以这种方式连接

TextStore

public class UpdateProfile:BaseModel
{

    public string firstName { get; set; }
    public string lastName { get; set; }
    public IFormFile Image { get; set; }
}

信号处理程序

typedef boost::signals2::signal<VOID(TextStore*,RECT*)> signal_GetCompExt;
signal_GetCompExt       m_sigGetCompExt;

连接信号

delegate VOID GetCompsitionExtDelegate(TextStore* textStore,RECT* rect);
VOID onGetCompsitionExt(TextStore* textStore,RECT* rect);

但它告诉我

using namespace System::Runtime::InteropServices;
    m_TextStore->m_sigGetCompExt.connect(reinterpret_cast<TextStore::signal_GetCompExt::slot_type*>(Marshal::GetFunctionPointerForDelegate(gcnew GetCompsitionExtDelegate(this,&AppWrapper::onGetCompsitionExt)).ToPointer()));

https://github.com/Windmill-City/libtf/blob/master/libtfWrapper/AppWrapper.cpp

在构建前设置Boost Root

路径:C2064 term does not evaluate to a function taking 2 arguments

BoostVersion boost_1_74_0

解决方法

typedef void (*GetCompExtCallback)(TextStore* ts,RECT* rect);
m_TextStore->m_sigGetCompExt.connect(reinterpret_cast<GetCompExtCallback>(Marshal::GetFunctionPointerForDelegate(gcnew GetCompsitionExtDelegate(this,&AppWrapper::onGetCompsitionExt)).ToPointer()));

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...