protected virtual void Dispose(bool disposing) { if (!_disposed) { if (disposing) { _queryTagCache.Dispose(); } _disposed = true; } }
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; }); }
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); }
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; }); }
public void Dispose() => _cache.Dispose();
public async ValueTask DisposeAsync() { _dicomFileCache.Dispose(); await _stream.DisposeAsync(); }