如何创建处理程序

发布于 2024-09-07 02:12:11 字数 1073 浏览 5 评论 0原文

添加下一个更改:

Emily::oSeMac^ Terminal;
    Emily::AsyncSocketController^ _socketManager;
    delegate void DataArrival(String^, array<unsigned char, 1>^, System::Net::IPEndPoint^);

    void _socketManager_onDataArrival(String^ SocketID, array<unsigned char, 1>^ SocketData, System::Net::IPEndPoint^ RemoteIP)
    {
        System::Object^ retData = Terminal->WhoCame (SocketID, SocketData, RemoteIP, _socketManager, 0); 
    }
    Form1(void)
    {
        InitializeComponent();
        _socketManager = gcnew Emily::AsyncSocketController(2000);
        _socketManager->onDataArrival += gcnew DataArrival(this, &AC_WebPassManager::Form1::_socketManager_onDataArrival);
        _socketManager->Start();
        Terminal = gcnew Emily::oSeMac();
    }

错误错误 C2664: 'Emily::AsyncSocketController::onDataArrival::add' : 无法将参数 1 从 'AC_WebPassManager::Form1::DataArrival ^' 转换为 'Emily::AsyncSocketController::onDataArrivalEventHandler ^' 1>没有可用的用户定义转换运算符,或者 1>指向的类型是不相关的;转换需要reinterpret_cast、C 风格转换或函数风格转换 1>

Add next changes:

Emily::oSeMac^ Terminal;
    Emily::AsyncSocketController^ _socketManager;
    delegate void DataArrival(String^, array<unsigned char, 1>^, System::Net::IPEndPoint^);

    void _socketManager_onDataArrival(String^ SocketID, array<unsigned char, 1>^ SocketData, System::Net::IPEndPoint^ RemoteIP)
    {
        System::Object^ retData = Terminal->WhoCame (SocketID, SocketData, RemoteIP, _socketManager, 0); 
    }
    Form1(void)
    {
        InitializeComponent();
        _socketManager = gcnew Emily::AsyncSocketController(2000);
        _socketManager->onDataArrival += gcnew DataArrival(this, &AC_WebPassManager::Form1::_socketManager_onDataArrival);
        _socketManager->Start();
        Terminal = gcnew Emily::oSeMac();
    }

Error error C2664: 'Emily::AsyncSocketController::onDataArrival::add' : cannot convert parameter 1 from 'AC_WebPassManager::Form1::DataArrival ^' to 'Emily::AsyncSocketController::onDataArrivalEventHandler ^'
1> No user-defined-conversion operator available, or
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

太阳公公是暖光 2024-09-14 02:12:11
_socketManager->onDataArrival += gcnew DataArrival(this,
    &Test::Form1::_socketManager_onDataArrival_);

DataArrival 是委托:

public delegate DataArrival(String^, array<unsigned char, 1>^, System::Net::IPEndPoint^);

可能它已经在某处以其他名称定义 - 在 Emily 命名空间中查看此委托定义。

_socketManager->onDataArrival += gcnew DataArrival(this,
    &Test::Form1::_socketManager_onDataArrival_);

DataArrival is delegate:

public delegate DataArrival(String^, array<unsigned char, 1>^, System::Net::IPEndPoint^);

Possibly it is already defined somewhere, with other name - look this delegate definition in Emily namespace.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文