我已经根据一些例子在Raspberry Pi 3上的Win 10 Core中实现了UWP TCP服务器。我为我使用的端口启用了Raspberry Pi 3防火墙。如果ConnectionReceived事件处理程序表示为委托,则StreamSocketListener可以连接并处理传入的客户端请求:
string serverPort = "8081";
StreamSocketListener listener = new StreamSocketListener();
await listener.BindServiceNameAsync(serverPort);
listener.ConnectionReceived += async (sender, args) =>{};
但是同一事件处理程序的经典表达式无法检测传入的客户端请求(连接):
string serverPort = "8081";
StreamSocketListener listener = new StreamSocketListener();
listener.ConnectionReceived += OnConnectionReceived;
await listener.BindServiceNameAsync(serverPort);
private async void OnConnectionReceived(StreamSocketListener sender,
StreamSocketListenerConnectionReceivedEventArgs args) {}.
请告诉我导致这种不同行为的原因以及如何解决经典事件处理程序的问题。