委托如何返回字符串生成器?

第一次

delegate System.Text.StringBuilder get_content_func(uint i);

然后

get_content_func func = _content;
System.IntPtr p = Marshal.GetFunctionPointerForDelegate(func);//error - stack over flow

并且'p'将被注册到c++,并且会在某个时间被回调以获取字符串内容。 C++部分

typedef char* (__stdcall* getcontenFunc)(unsigned int id);//char*
void register_get_page_content(getcontenFunc GetHandle) {
        g_GetHandle = GetHandle;//g_GetHanle is a global pointer
}

//func to call g_GetHandle

void get_page(guid id) {
        char* content;
        if (g_GetHandle != nullptr) {
            content = g_GetHandle(id);
        }
    }

目的是从方法 '_content ' 中获取字符串,该方法用于发送到 cpp 以执行其他操作。 'p' 将是一个回调函数,用于通过 stringbuilder 获取内容。 但是失败了,怎么解决?

zyh810908 回答:委托如何返回字符串生成器?

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/50275.html

大家都在问