Пример #1
0
        /// <summary>
        /// Stop the server.  This notifies the listener to stop accepting new connections
        /// and that the loop should exit.
        /// </summary>
        public void Stop()
        {
            _log.Debug("Trying to stop SmtpServer.");

            try
            {
                lock (this)
                {
                    // Kick the server accept loop
                    if (_tcpListener != null)
                    {
                        _processor.Stop();
                        _log.Debug("Stopping tcp listener.");
                        _tcpListener.Stop();
                        _log.Debug("Tcp listener stopped.");
                    }
                    _tcpListener = null;
                }
            }
            catch (Exception ex)
            {
                _log.Warn("Unexpected Exception stopping SmtpServer", ex);
            }
            finally
            {
                _log.Debug("SmtpServer Stopped.");
                _clientConnected.Set();
                _serverReady.Close();
            }
        }