hMailServer.Core.SessionManager.IncreaseSessionCount C# (CSharp) Метод

IncreaseSessionCount() публичный статический Метод

public static IncreaseSessionCount ( Protocol protocol ) : void
protocol Protocol
Результат void
        public static void IncreaseSessionCount(Protocol protocol)
        {
            switch (protocol)
            {
                case Protocol.IMAPD:
                    Interlocked.Increment(ref _imapdSessionCount);
                    break;
                case Protocol.POP3D:
                    Interlocked.Increment(ref _pop3dSessionCount);
                    break;
                case Protocol.SMTPD:
                    Interlocked.Increment(ref _smtpdSessionCount);
                    break;
            }
        }

Usage Example

Пример #1
0
        public async Task RunAsync()
        {
            _listener.Start();

            while (true)
            {
                TcpClient tcpClient = null;

                try
                {
                    tcpClient = await _listener.AcceptTcpClientAsync();
                }
                catch (ObjectDisposedException)
                {
                    // When TcpListener is stopped, outstanding calls to AcceptTcpClientAsync
                    // will throw an ObjectDisposedException. When this happens, it's time to
                    // exit.
                    return;
                }


                var connection = new Connection(tcpClient, _cancellationTokenSource.Token);

                var session = _sessionFactory();

                var sessionTask = session.HandleConnection(connection);

                SessionManager.IncreaseSessionCount(session.Protocol);

                HandleSessionAsynchronously(sessionTask, connection, session);
            }
        }