public void Dispose() { if (_disposed) { return; } _disposed = true; _serviceScope.Dispose(); // Check if the shell has been terminated. if (_shellTerminated) { ShellContext.Dispose(); } if (!_terminated) { // Keep the counter clean if not yet decremented. Interlocked.Decrement(ref ShellContext._refCount); } var holder = _current.Value; if (holder != null) { // Clear the current scope that may be trapped in some execution contexts. holder.Scope = null; } }
public void Dispose() { // The last use disposes the shell context. if (Interlocked.Decrement(ref _count) == 0) { _context.Dispose(); } }
public async Task DisposeAsync() { if (_disposed) { return; } var disposeShellContext = _disposeShellContext || await TerminateShellAsync(); _serviceScope.Dispose(); if (disposeShellContext) { ShellContext.Dispose(); } // Decrement the counter at the very end of the scope Interlocked.Decrement(ref ShellContext._refCount); _disposed = true; }
public void Dispose() { if (_disposed) { return; } _disposed = true; _serviceScope.Dispose(); // Check if the shell has been terminated. if (_shellTerminated) { ShellContext.Dispose(); } if (!_terminated) { // Keep the counter clean if not yet decremented. Interlocked.Decrement(ref ShellContext._refCount); } }
public void Dispose() { _workContextScope.Dispose(); _shellContext.Dispose(); }