Amib.Threading.CallerThreadContext.Capture C# (CSharp) Метод

Capture() публичный статический Метод

Captures the current thread context
public static Capture ( bool captureCallContext, bool captureHttpContext ) : CallerThreadContext
captureCallContext bool
captureHttpContext bool
Результат CallerThreadContext
        public static CallerThreadContext Capture(
            bool captureCallContext,
            bool captureHttpContext)
        {
            Debug.Assert(captureCallContext || captureHttpContext);

            var callerThreadContext = new CallerThreadContext();

            // TODO: In NET 2.0, redo using the new feature of ExecutionContext class - Capture()
            // Capture Call Context
            if (captureCallContext && (getLogicalCallContextMethodInfo != null))
            {
                callerThreadContext._callContext =
                    (LogicalCallContext) getLogicalCallContextMethodInfo.Invoke(Thread.CurrentThread, null);
                if (callerThreadContext._callContext != null)
                {
                    callerThreadContext._callContext = (LogicalCallContext) callerThreadContext._callContext.Clone();
                }
            }

            // Capture httpContext
            if (captureHttpContext && (null != HttpContext.Current))
            {
                callerThreadContext._httpContext = HttpContext.Current;
            }

            return callerThreadContext;
        }