Reputation: 2371
I'm having trouble understanding the clrzmq (3.0.0 rc1) Socket.ReceiveReady event. In idiomatic C# code I would expect to register an event handler and then sit back and wait for the handler to be called:
socket.ReceiveReady += (o, e) => Console.WriteLine ("Success!");
However this event is never raised unless I also actively poll:
var poller = new Poller( new[] {socket} );
while (true) {
poller.Poll();
}
This is completely counter-intuitive to me: I should either poll (i.e use a pull-based model) or listen for an event (i.e. use a push-based model).
So, is this really the correct approach, or am I missing something simpler?
Upvotes: 4
Views: 1076
Reputation: 3419
Yes, it appears to be the correct approach. In NetMQ those events are only called by NetMQSocket.Poll()
and Poller.Start()
. Polling is needed because there needs to be a dedicated thread to process messages from the socket.
Upvotes: 4