Пример #1
0
        protected override void Dispose(bool disposing)
        {
            if (_disposed)
            {
                return;
            }
            _disposed = true;

            if (disposing)
            {
                if (_aliveTimer != null)
                {
                    try
                    {
                        _aliveTimer.Dispose();
                    }
                    catch (Exception)
                    {
                    }

                    _aliveTimer = null;
                }

                if (_cap != null)
                {
                    try
                    {
                        _cap.Dispose();
                    }
                    catch (Exception)
                    {
                    }

                    _cap = null;
                }

                if (_bandwidthLimit != null)
                {
                    try
                    {
                        _bandwidthLimit.Leave(this);
                    }
                    catch (Exception)
                    {
                    }

                    _bandwidthLimit = null;
                }

                _connect = false;
            }
        }
Пример #2
0
        public BaseConnection(CapBase cap, BandwidthLimit bandwidthLimit, int maxReceiveCount, BufferManager bufferManager)
        {
            _cap             = cap;
            _bandwidthLimit  = bandwidthLimit;
            _maxReceiveCount = maxReceiveCount;
            _bufferManager   = bufferManager;

            if (_bandwidthLimit != null)
            {
                _bandwidthLimit.Join(this);
            }

            _aliveTimer = new System.Threading.Timer(this.AliveTimer, null, 1000 * 30, 1000 * 30);
            _aliveStopwatch.Start();

            _connect = true;
        }