/// <summary> /// Stops the proxy, blocking until the underlying <see cref="NetMQPoller"/> has completed. /// </summary> /// <exception cref="InvalidOperationException">The proxy has not been started.</exception> public void Stop() { if (Interlocked.CompareExchange(ref m_state, StateStopping, StateStarted) != StateStarted) { throw new InvalidOperationException("Proxy has not been started"); } if (!m_externalPoller) { m_poller.Stop(); m_poller.Dispose(); m_poller = null; } m_frontend.ReceiveReady -= OnFrontendReady; m_backend.ReceiveReady -= OnBackendReady; m_state = StateStopped; }
/// <summary> /// Stop the device and safely close the underlying sockets. /// </summary> /// <param name="waitForCloseToComplete">If true, this method will block until the /// underlying poller is fully stopped. Defaults to true.</param> public void Stop(bool waitForCloseToComplete = true) { if (m_pollerIsOwned && m_poller.IsRunning) { if (waitForCloseToComplete) { m_poller.Stop(); } else { m_poller.StopAsync(); } } FrontendSocket.Close(); BackendSocket.Close(); m_poller.Dispose(); IsRunning = false; }
/// <summary> /// Stops active monitoring of transports /// </summary> public void StopMonitoring() { lock (lockObj) { if (!running) { return; } poller.StopAsync(); poller.Dispose(); foreach (var sender in senders) { sender.TerminateConnection(); } foreach (var receiver in receivers) { receiver.TerminateConnection(); } foreach (var publisher in publishers) { publisher.TerminateConnection(); } foreach (var subscriber in subscribers) { subscriber.TerminateConnection(); } NetMQConfig.Cleanup(false); running = false; } }