Exemplo n.º 1
0
        public override void Close(TimeSpan timeout, Information options)
        {
            if (_disposed)
            {
                throw new ObjectDisposedException(this.GetType().FullName);
            }
            if (!_connect)
            {
                throw new ConnectionException();
            }

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

                    _cap = null;
                }

                _connect = false;
            }
        }
Exemplo n.º 2
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;
            }
        }
Exemplo n.º 3
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;
        }