RouterSocket.ReceiveReady 无限调用

问题描述 投票:0回答:1

我有发送消息然后得到回复的 RouterSocket,问题是 ReceiveReady 无限触发。

这里是我的代码:

using NetMQ;
using NetMQ.Sockets;
using System.Text;

RouterSocket router = new RouterSocket();
router.Connect("tcp://127.0.0.1:8976");
router.ReceiveReady += RouterSocket_ReceiveReady;
router.SendFrame(Encoding.ASCII.GetBytes("Hello"));


NetMQPoller poller = new NetMQPoller{router};
poller.Run();

void RouterSocket_ReceiveReady(object? sender, NetMQSocketEventArgs e)
{
    var message = router.ReceiveMultipartMessage();
    Console.WriteLine($"Received: {message}");
}

 Console.WriteLine($"Received: {message}");
一次又一次地打印响应

c# zeromq netmq
1个回答
0
投票

除非您从另一个线程调用 Stop 或 StopAsync,否则这是预期的功能。

© www.soinside.com 2019 - 2024. All rights reserved.