Beispiel #1
0
        /// <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();
            IsRunning = false;
        }
Beispiel #2
0
        /// <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;
            }
        }
 public Task StopAsync(CancellationToken cancellationToken)
 {
     _poller.StopAsync();
     return(Task.CompletedTask);
 }