public void SubsriberCleanupOnUnbind(string address) { for (var i = 0; i < 10; i++) { using (var sub = new SubscriberSocket()) { sub.Bind(address); using (var monitor = new NetMQMonitor(sub, String.Format("inproc://cleanup.test{0}", Guid.NewGuid()), SocketEvents.Closed)) { var monitorTask = Task.Factory.StartNew(monitor.Start); var closed = new ManualResetEventSlim(); monitor.Closed += (sender, args) => closed.Set(); var time = DateTime.Now; sub.Unbind(address); Assert.That(closed.Wait(1000), Is.True, "Unbind failed to report Closed event to the Monitor"); var duration = DateTime.Now - time; Console.WriteLine("Run {0}: {1} ms", i, duration.TotalMilliseconds); monitor.Stop(); monitorTask.Wait(); } } } }
protected override void OnStop(SubscriberSocket socket) { socket.Unbind(_address); }