netDumbster.smtp.SimpleSmtpServer.Stop C# (CSharp) Méthode

Stop() public méthode

Stop the server. This notifies the listener to stop accepting new connections and that the loop should exit.
public Stop ( ) : void
Résultat void
        public void Stop()
        {
            this.log.Debug("Trying to stop SmtpServer.");

            try
            {
                lock (this)
                {
                    this.stop = true;

                    // Kick the server accept loop
                    if (this.tcpListener != null)
                    {
                        // _processor.Stop();
                        this.log.Debug("Stopping tcp listener.");
                        this.tcpListener.Stop();
                        this.log.Debug("Tcp listener stopped.");
                    }

                    this.tcpListener = null;
                }
            }
            catch (Exception ex)
            {
                this.log.Warn("Unexpected Exception stopping SmtpServer", ex);
            }
            finally
            {
                this.log.Debug("SmtpServer Stopped.");
                this.ServerReady.Close();
            }
        }

Usage Example

 public static void StopEmailServer(SimpleSmtpServer server)
 {
     if(server != null)
     {
         server.Stop();
     }
 }