示例#1
0
        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;
            }
        }
示例#2
0
 public void Dispose()
 {
     // The last use disposes the shell context.
     if (Interlocked.Decrement(ref _count) == 0)
     {
         _context.Dispose();
     }
 }
示例#3
0
        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;
        }
示例#4
0
        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);
            }
        }
示例#5
0
 public void Dispose()
 {
     _workContextScope.Dispose();
     _shellContext.Dispose();
 }