Пример #1
0
 private void DisposeManaged()
 {
     Stop(true);
     _workerCTS?.Dispose();
     _workerTask?.Dispose();
     _ratesLock?.Dispose();
 }
Пример #2
0
 protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         _lock?.Dispose();
     }
 }
Пример #3
0
        public void Dispose()
        {
            if (_cacheLock == null)
            {
                return;
            }

            _cacheLock.EnterWriteLock();
            try
            {
                var services = _innerCache.Values.ToArray();
                foreach (var service in services)
                {
                    var disposable = service as IDisposable;
                    disposable?.Dispose();
                }
                _innerCache.Clear();
            }
            finally
            {
                _cacheLock.ExitWriteLock();
                _cacheLock?.Dispose();
                _cacheLock = null;
            }
        }
 public void Dispose()
 {
     if (_scheduler != null)
     {
         _scheduler.Subscribe -= SchedulerOnSubscribe;
     }
     _readerWriterLock?.Dispose();
 }
Пример #5
0
 /// <inheritdoc />
 public void Dispose()
 {
     if (_isDisposed)
     {
         return;
     }
     _isDisposed = true;
     _locker?.Dispose();
     _locker = null;
 }
Пример #6
0
 /// <summary>
 /// Disposes the <see cref="ConcurrentCollection{T}"/> with the internal <see cref="ReaderWriterLockSlim"/> object.
 /// </summary>
 public void Dispose()
 {
     try
     {
         _lock?.Dispose();
     }
     catch
     {
     }
 }
 /// <summary>
 /// Releases unmanaged and - optionally - managed resources.
 /// </summary>
 /// <param name="alsoManaged"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>
 private void Dispose(bool alsoManaged)
 {
     if (IsDisposed)
     {
         return;
     }
     IsDisposed = true;
     Locker?.Dispose();
     Locker = null;
 }
Пример #8
0
 protected virtual void Dispose(bool disposing)
 {
     if (!_disposedValue)
     {
         if (disposing)
         {
             _locker.Dispose();
         }
         _disposedValue = true;
     }
 }
Пример #9
0
        public void Dispose()
        {
            if (_treeLock != null)
            {
                Debug.Assert(!_treeLock.IsWriteLockHeld);
                Debug.Assert(!_treeLock.IsReadLockHeld);

                _treeLock.Dispose();
                _treeLock = null;
            }
        }
Пример #10
0
 protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         if (_lock != null)
         {
             _lock.Dispose();
             _lock = null;
         }
     }
 }
        public void Dispose_WithWriteLock()
        {
            var rwl = new ReaderWriterLockSlim();

            rwl.EnterWriteLock();
            try {
                rwl.Dispose();
                Assert.Fail("1");
            } catch (SynchronizationLockException) {
            }
        }
        public void EntersWriteLock()
        {
            var slim = new ReaderWriterLockSlim();

            var token = slim.Write();

            Assert.IsTrue(slim.IsWriteLockHeld);
            slim.ExitWriteLock();

            slim.Dispose();
        }
 protected virtual void Dispose(bool Disposing)
 {
     OnCompleted();
     if (Disposing)
     {
         ViewModel?.Dispose();
         _readWriteLock?.Dispose();
         _snapshotLock?.Dispose();
     }
     _isDisposed = true;
 }
        public void ExitsWriteLock()
        {
            var slim = new ReaderWriterLockSlim();

            var token = slim.Read();

            token.Dispose();
            Assert.IsFalse(slim.IsReadLockHeld);

            slim.Dispose();
        }
Пример #15
0
        /// <summary>
        /// Disposes this instance by freeing all the owned entries.
        /// </summary>
        /// <param name="disposeManaged">See <see cref="Disposable.Dispose(bool)"/>.</param>
        protected override void Dispose(bool disposeManaged)
        {
            if (disposeManaged)
            {
                //
                // Itt ne "this.Where()"-t hivjunk mert az feleslegesen lock-olna.
                //

                foreach (IDisposable disposable in FEntries.Values.Where(ShouldDispose))
                {
                    disposable.Dispose();
                }

                FEntries.Clear();

                FLock.Dispose();
            }

            base.Dispose(disposeManaged);
        }
Пример #16
0
            public void Dispose()
            {
                if (_isDisposed)
                {
                    return;
                }

                _isDisposed = true;
                _lock.Dispose();
                _cancellationTokenSource.Dispose();
            }
Пример #17
0
        protected virtual void Dispose(bool disposing)
        {
            if (_isDisposed || !disposing)
            {
                return;
            }
            _isDisposed = true;

            State.ParseRequest -= ReparseRequested;
            Cancel(false);
            ParsingSuspendLock.Dispose();
        }
Пример #18
0
 // The bulk of the clean-up code is implemented in Dispose(bool)
 protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         // free managed resources
         if (rwl != null)
         {
             rwl.Dispose();
             rwl = null;
         }
     }
 }
Пример #19
0
        protected virtual void Dispose(bool disposing)
        {
            if (!m_objectDisposed)
            {
                if (disposing)
                {
                    m_dataUnitsLock.Dispose();
                }

                m_objectDisposed = true;
            }
        }
 protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         if (!_isDisposed)
         {
             _isDisposed = true;
             _lock.Dispose();
             _lock = null;
         }
     }
 }
Пример #21
0
        protected virtual void Dispose(bool disposing)
        {
            if (!hasDisposed)
            {
                if (disposing)
                {
                    _processLock.Dispose();
                }

                hasDisposed = true;
            }
        }
 protected virtual void Dispose(bool disposing)
 {
     if (disposing && !_disposed)
     {
         if (_rwLock != null)
         {
             _rwLock.Dispose();
         }
         _rwLock   = null;
         _disposed = true;
     }
 }
Пример #23
0
        public void Dispose()
        {
            if (_isDisposed)
            {
                return;
            }

            _sha256?.Dispose();
            _lock?.Dispose();

            _isDisposed = true;
        }
Пример #24
0
 private void Dispose(bool disposing)
 {
     if (!disposed)
     {
         if (disposing)
         {
             cancelToken.Cancel();
             _locker.Dispose();
         }
         disposed = true;
     }
 }
Пример #25
0
        /// <summary>
        /// Protected vitual member of the dispose pattern.
        /// </summary>
        /// <param name="disposing">Call came from Dispose.</param>
        protected virtual void Dispose(bool disposing)
        {
            if (!_disposed)
            {
                if (disposing)
                {
                    _lock.Dispose();
                }

                _disposed = true;
            }
        }
Пример #26
0
 // The bulk of the clean-up code is implemented in Dispose(bool)
 protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         // free managed resources
         if (slimLock != null)
         {
             slimLock.Dispose();
             slimLock = null;
         }
     }
 }
 /// <summary>
 /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
 /// </summary>
 /// <filterpriority>2</filterpriority>
 public void Dispose()
 {
     Stop();
     if (_blockingCollection != null)
     {
         _blockingCollection.Dispose();
     }
     if (_lock != null)
     {
         _lock.Dispose();
     }
 }
Пример #28
0
 /// <summary>
 /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
 /// </summary>
 /// <filterpriority>2</filterpriority>
 public void Dispose()
 {
     Stop();
     if (_queue != null)
     {
         _queue.Clear();
     }
     if (_lock != null)
     {
         _lock.Dispose();
     }
 }
 protected virtual void Dispose(bool disposing)
 {
     if (disposed)
     {
         return;
     }
     if (disposing)
     {
         rwlock.Dispose();
     }
     disposed = true;
 }
Пример #30
0
        protected virtual void Dispose(bool disposing)
        {
            if (!disposedValue)
            {
                if (disposing)
                {
                    _readerWriterLock.Dispose();
                }

                disposedValue = true;
            }
        }
Пример #31
0
        public static void Dispose()
        {
            ReaderWriterLockSlim rwls;

            rwls = new ReaderWriterLockSlim();
            rwls.Dispose();
            Assert.Throws<ObjectDisposedException>(() => rwls.TryEnterReadLock(0));
            Assert.Throws<ObjectDisposedException>(() => rwls.TryEnterUpgradeableReadLock(0));
            Assert.Throws<ObjectDisposedException>(() => rwls.TryEnterWriteLock(0));
            rwls.Dispose();

            for (int i = 0; i < 3; i++)
            {
                rwls = new ReaderWriterLockSlim();
                switch (i)
                {
                    case 0: rwls.EnterReadLock(); break;
                    case 1: rwls.EnterUpgradeableReadLock(); break;
                    case 2: rwls.EnterWriteLock(); break;
                }
                Assert.Throws<SynchronizationLockException>(() => rwls.Dispose());
            }
        }