private ThreadInfo( bool propogateThreadPrincipal, bool propogateCallContext, bool propogateHttpContext, bool propogateCASMarkers ) { if( propogateThreadPrincipal ) { principal = Thread.CurrentPrincipal; } if( propogateHttpContext ) { httpContext = HostContext.Current; } if( propogateCallContext && (miGetLogicalCallContext != null) ) { callContext = (LogicalCallContext)miGetLogicalCallContext.Invoke(Thread.CurrentThread, null); callContext = (LogicalCallContext)callContext.Clone(); // TODO: consider serialize/deserialize call context to get a MBV snapshot // instead of leaving it up to the Clone method. } if( propogateCASMarkers ) { // TODO: Uncomment the following when Thread.GetCompressedStack is no longer guarded // by a StrongNameIdentityPermission. // // compressedStack = Thread.CurrentThread.GetCompressedStack(); } }
public ExecutionContext CreateCopy() { if (!this.isNewCapture) { throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_CannotCopyUsedContext")); } ExecutionContext context = new ExecutionContext { isNewCapture = true, _syncContext = (this._syncContext == null) ? null : this._syncContext.CreateCopy(), _hostExecutionContext = (this._hostExecutionContext == null) ? null : this._hostExecutionContext.CreateCopy() }; if (this._securityContext != null) { context._securityContext = this._securityContext.CreateCopy(); context._securityContext.ExecutionContext = context; } if (this._logicalCallContext != null) { System.Runtime.Remoting.Messaging.LogicalCallContext logicalCallContext = this.LogicalCallContext; context.LogicalCallContext = (System.Runtime.Remoting.Messaging.LogicalCallContext)logicalCallContext.Clone(); } if (this._illogicalCallContext != null) { System.Runtime.Remoting.Messaging.IllogicalCallContext illogicalCallContext = this.IllogicalCallContext; context.IllogicalCallContext = (System.Runtime.Remoting.Messaging.IllogicalCallContext)illogicalCallContext.Clone(); } return(context); }
public LogicalCallContext Clone() { return((LogicalCallContext)m_ctx.Clone()); }
internal static ExecutionContext Capture(ref StackCrawlMark stackMark) { if (IsFlowSuppressed()) { return(null); } ExecutionContext executionContextNoCreate = System.Threading.Thread.CurrentThread.GetExecutionContextNoCreate(); ExecutionContext context2 = new ExecutionContext { isNewCapture = true, SecurityContext = System.Security.SecurityContext.Capture(executionContextNoCreate, ref stackMark) }; if (context2.SecurityContext != null) { context2.SecurityContext.ExecutionContext = context2; } context2._hostExecutionContext = HostExecutionContextManager.CaptureHostExecutionContext(); if (executionContextNoCreate != null) { context2._syncContext = (executionContextNoCreate._syncContext == null) ? null : executionContextNoCreate._syncContext.CreateCopy(); if (executionContextNoCreate._logicalCallContext != null) { System.Runtime.Remoting.Messaging.LogicalCallContext logicalCallContext = executionContextNoCreate.LogicalCallContext; context2.LogicalCallContext = (System.Runtime.Remoting.Messaging.LogicalCallContext)logicalCallContext.Clone(); } } return(context2); }