zeromq / netmq

A 100% native C# implementation of ZeroMQ for .NET
Other
2.95k stars 744 forks source link

Poller's callbacks can be called even after it is stopped #900

Closed mrakgr closed 2 years ago

mrakgr commented 4 years ago

Environment

NetMQ Version:    4.0.1.2-pre
Operating System: Windows 10
.NET Version:     .NET Core 3.1

Expected behaviour

Calling Stop renders it inactive.

Actual behaviour

The poller continues working for one more iteration. Unlike for my previous issues, this happens on the first iteration.

Steps to reproduce the behaviour

Run the last example in the UI. What happens is that the two of the workers get printed twice.

In particular, in...

use __ = req.SendReady.Subscribe(fun _ -> 
    req.SendFrame("Hi Boss")
    let msg = req.ReceiveFrameString()
    if msg.ToString() = msg_fired then poller.Stop(); log <| sprintf "Completed %d tasks." !total
    else Thread.Sleep(rnd.Next(1,500)); incr total
    )

...that log gets triggered twice.

This behavior took me completely by surprise. For all I know though, this might be intentional to give a few more messages a chance to be processed. Which case is it?

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had activity for 365 days. It will be closed if no further activity occurs within 56 days. Thank you for your contributions.