Dispose() private method

private Dispose ( ) : void
return void
コード例 #1
0
ファイル: AsyncServer.cs プロジェクト: quangfox/TCPChat
        private void ReleaseManagedResource()
        {
            if (disposed)
            {
                return;
            }

            isServerRunning = false;

            if (requestQueue != null)
            {
                requestQueue.Dispose();
            }

            lock (timerSync)
            {
                if (systemTimer != null)
                {
                    systemTimer.Dispose();
                }

                systemTimer = null;
            }

            lock (connections)
            {
                foreach (var connection in connections.Values)
                {
                    connection.Dispose();
                }

                connections.Clear();
            }

            if (listener != null)
            {
                listener.Close();
            }

            if (p2pService != null)
            {
                p2pService.Dispose();
            }

            disposed = true;
        }
コード例 #2
0
        private void DisposeManagedResources()
        {
            _isServerRunning = false;

            if (_requestQueue != null)
            {
                _requestQueue.Dispose();
            }

            lock (_timerSync)
            {
                if (_systemTimer != null)
                {
                    _systemTimer.Dispose();
                }

                _systemTimer = null;
            }

            lock (_connections)
            {
                foreach (var connection in _connections.Values)
                {
                    connection.Dispose();
                }

                _connections.Clear();
            }

            if (_listener != null)
            {
                _listener.Dispose();
                _listener = null;
            }

            if (_p2pService != null)
            {
                _p2pService.Dispose();
                _p2pService = null;
            }
        }