internal ExecutionContextScope BeginExecutionContextScope() { var parentScope = this.CurrentScope; var scope = new ExecutionContextScope(this, parentScope); this.CurrentScope = scope; return scope; }
internal ExecutionContextScope BeginExecutionContextScope() { var parentScope = this.CurrentScope; var scope = new ExecutionContextScope(this, parentScope); this.CurrentScope = scope; return(scope); }
internal void EndExecutionContextScope(ExecutionContextScope scope) { // If the scope is not the current scope or one of its ancestors, this means that either one of // the scope's parents have already been disposed, or the scope is disposed on a completely // unrelated thread. In both cases we shouldn't change the CurrentScope, since doing this, // since would cause an invalid scope to be registered as the current scope (this scope will // either be disposed or does not belong to the current execution context). if (this.IsScopeInLocalChain(scope)) { this.CurrentScopeInternal = scope.ParentScope; } }
internal void EndExecutionContextScope(ExecutionContextScope scope) { // If the scope is not the current scope or one of its ancestors, this means that either one of // the scope's parents have already been disposed, or the scope is disposed on a completely // unrelated thread. In both cases we shouldn't change the CurrentScope, since doing this, // since would cause an invalid scope to be registered as the current scope (this scope will // either be disposed or does not belong to the current execution context). if (scope.IsCurrentScopeOrAncestor) { this.CurrentScope = scope.ParentScope; } }
// Determines whether this instance is the currently registered execution context scope or an ancestor // of it. private bool IsScopeInLocalChain(ExecutionContextScope scope) { var currentScope = this.CurrentScopeInternal; while (currentScope != null) { if (object.ReferenceEquals(scope, currentScope)) { return true; } currentScope = currentScope.ParentScope; } return false; }
// Determines whether this instance is the currently registered execution context scope or an ancestor // of it. private bool IsScopeInLocalChain(ExecutionContextScope scope) { var currentScope = this.CurrentScopeInternal; while (currentScope != null) { if (object.ReferenceEquals(scope, currentScope)) { return(true); } currentScope = currentScope.ParentScope; } return(false); }
internal ExecutionContextScopeWrapper(ExecutionContextScope scope) { this.Scope = scope; }