Exemple #1
0
        protected virtual void Dispose(bool disposing)
        {
            if (!_disposed)
            {
                if (disposing)
                {
                    _queryTagCache.Dispose();
                }

                _disposed = true;
            }
        }
Exemple #2
0
        public void AccessingTaskAfterDisposeThrowsTest()
        {
            Task <int> update(CancellationToken c)
            {
                return(Task.FromResult(0));
            }

            var asyncCache = new AsyncCache <int>(update);

            asyncCache.Dispose();

            Assert.ThrowsException <ObjectDisposedException>(() =>
            {
                _ = asyncCache.Task;
            });
        }
Exemple #3
0
        public void DisposeTest()
        {
            var revision = 0;
            CancellationToken cancellation;

            async Task <int> update(CancellationToken c)
            {
                cancellation = c;
                var r = Interlocked.Increment(ref revision);
                await Task.Delay(50, c);

                return(r);
            }

            var asyncCache = new AsyncCache <int>(update);
            var task       = asyncCache.Task;

            asyncCache.Dispose();

            Assert.IsTrue(cancellation.IsCancellationRequested);
        }
Exemple #4
0
        public async Task AwaitingTaskAfterDisposeThrowsTest()
        {
            var revision = 0;
            CancellationToken cancellation;

            async Task <int> update(CancellationToken c)
            {
                cancellation = c;
                var r = Interlocked.Increment(ref revision);
                await Task.Delay(50);

                return(r);
            }

            var asyncCache = new AsyncCache <int>(update);
            var task       = asyncCache.Task;

            asyncCache.Dispose();

            await Assert.ThrowsExceptionAsync <ObjectDisposedException>(async() =>
            {
                await task;
            });
        }
Exemple #5
0
 public void Dispose()
 => _cache.Dispose();
Exemple #6
0
 public async ValueTask DisposeAsync()
 {
     _dicomFileCache.Dispose();
     await _stream.DisposeAsync();
 }