我正在使用Visual Studio 2017中来自here的示例代码通过RFCOMM套接字设置蓝牙服务器。 当我使用TypedEventHandler时:
auto listener = ref new StreamSocketListener();
listener->ConnectionReceived += ref new TypedEventHandler
<StreamSocketListener^,
StreamSocketListenerConnectionReceivedEventArgs^>
(this, &HolographicTestAppMainV2::OnConnectionReceived);
使用OnConnectrionReceived函数:
void HolographicTestAppMainV2::OnConnectionReceived(StreamSocketListener^
listener, StreamSocketListenerConnectionReceivedEventArgs^ args)
{
// Stop advertising/listening so that we're only serving one client
_provider->StopAdvertising();
delete listener;
_socket = args->Socket;
....
}
错误信息不断弹出:
E2161无效的委托初始值设定项 - 函数不是C ++ / CX类的成员
我通读了delegates的文档,看起来与我写的相同,这让我很困惑。