当前位置: 首页>>代码示例>>C#>>正文


C# ExecutionContext.IsDefaultFTContext方法代码示例

本文整理汇总了C#中System.Threading.ExecutionContext.IsDefaultFTContext方法的典型用法代码示例。如果您正苦于以下问题:C# ExecutionContext.IsDefaultFTContext方法的具体用法?C# ExecutionContext.IsDefaultFTContext怎么用?C# ExecutionContext.IsDefaultFTContext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Threading.ExecutionContext的用法示例。


在下文中一共展示了ExecutionContext.IsDefaultFTContext方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Run

        public static void Run(ExecutionContext executionContext, ContextCallback callback,  Object state)
        {
            if (executionContext == null )
            {
                throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_NullContext"));
            }

            if (!executionContext.isNewCapture)
            {
                throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_NotNewCaptureContext"));
            }
            
            executionContext.isNewCapture = false;
            
            ExecutionContext ec = Thread.CurrentThread.GetExecutionContextNoCreate();
            if ( (ec == null || ec.IsDefaultFTContext()) && SecurityContext.CurrentlyInDefaultFTSecurityContext(ec)
                && executionContext.IsDefaultFTContext())
            {
                callback(state);
            }
            else
            {
                RunInternal(executionContext, callback, state);
            }
        }
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:25,代码来源:executioncontext.cs

示例2: Run

        [System.Security.SecurityCritical]  // auto-generated_required
        internal static void Run(ExecutionContext executionContext, ContextCallback callback,  Object state, bool ignoreSyncCtx) 
        {
            Contract.Assert(executionContext != s_dummyDefaultEC || executionContext.IsDefaultFTContext(ignoreSyncCtx)); 
            if (executionContext == null) 
            {
                throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_NullContext")); 
            }
            if (!executionContext.isNewCapture && executionContext != s_dummyDefaultEC)
            {
                throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_NotNewCaptureContext")); 
            }
 
            if (executionContext != s_dummyDefaultEC) 
                executionContext.isNewCapture = false;
 
            ExecutionContext ec = Thread.CurrentThread.GetExecutionContextNoCreate();
            if ( (ec == null || ec.IsDefaultFTContext(ignoreSyncCtx)) &&
#if FEATURE_IMPERSONATION || FEATURE_COMPRESSEDSTACK
                SecurityContext.CurrentlyInDefaultFTSecurityContext(ec) && 
#endif // #if FEATURE_IMPERSONATION || FEATURE_COMPRESSEDSTACK
                executionContext.IsDefaultFTContext(ignoreSyncCtx)) 
            { 
                callback(state);
            } 
            else
            {
                if (executionContext == s_dummyDefaultEC)
                    executionContext = s_dummyDefaultEC.CreateCopy(); 
                RunInternal(executionContext, callback, state);
            } 
        } 
开发者ID:sjyanxin,项目名称:WPFSource,代码行数:32,代码来源:ExecutionContext.cs

示例3: RunInternal

        internal static void RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, bool preserveSyncCtx)
        {
            Contract.Assert(executionContext != null);
            if (executionContext.IsPreAllocatedDefault)
            {
                Contract.Assert(executionContext.IsDefaultFTContext(preserveSyncCtx));
            }
            else
            {
                Contract.Assert(executionContext.isNewCapture);
                executionContext.isNewCapture = false;
            }

            Thread currentThread = Thread.CurrentThread;
            ExecutionContextSwitcher ecsw = default(ExecutionContextSwitcher);

            RuntimeHelpers.PrepareConstrainedRegions();
            try
            {
                ExecutionContext.Reader ec = currentThread.GetExecutionContextReader();
                if ( (ec.IsNull || ec.IsDefaultFTContext(preserveSyncCtx)) && 
    #if FEATURE_IMPERSONATION || FEATURE_COMPRESSEDSTACK                
                    SecurityContext.CurrentlyInDefaultFTSecurityContext(ec) && 
    #endif // #if FEATURE_IMPERSONATION || FEATURE_COMPRESSEDSTACK                
                    executionContext.IsDefaultFTContext(preserveSyncCtx))
                {
                    // Neither context is interesting, so we don't need to set the context.
                    // We do need to reset any changes made by the user's callback,
                    // so here we establish a "copy-on-write scope".  Any changes will
                    // result in a copy of the context being made, preserving the original
                    // context.
                    EstablishCopyOnWriteScope(currentThread, true, ref ecsw);
                }
                else
                {
                    if (executionContext.IsPreAllocatedDefault)
                        executionContext = executionContext.CreateCopy();
                    ecsw = SetExecutionContext(executionContext, preserveSyncCtx);
                }

                //
                // Call the user's callback
                //
                callback(state);
            }
            finally
            {
                ecsw.Undo(currentThread);
            }
        }
开发者ID:stormleoxia,项目名称:referencesource,代码行数:50,代码来源:executioncontext.cs

示例4: Run

 internal static void Run(ExecutionContext executionContext, ContextCallback callback, object state, bool ignoreSyncCtx)
 {
     if (executionContext == null)
     {
         throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_NullContext"));
     }
     if (!executionContext.isNewCapture && (executionContext != s_dummyDefaultEC))
     {
         throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_NotNewCaptureContext"));
     }
     if (executionContext != s_dummyDefaultEC)
     {
         executionContext.isNewCapture = false;
     }
     ExecutionContext executionContextNoCreate = System.Threading.Thread.CurrentThread.GetExecutionContextNoCreate();
     if (((executionContextNoCreate == null) || executionContextNoCreate.IsDefaultFTContext(ignoreSyncCtx)) && (System.Security.SecurityContext.CurrentlyInDefaultFTSecurityContext(executionContextNoCreate) && executionContext.IsDefaultFTContext(ignoreSyncCtx)))
     {
         callback(state);
     }
     else
     {
         if (executionContext == s_dummyDefaultEC)
         {
             executionContext = s_dummyDefaultEC.CreateCopy();
         }
         RunInternal(executionContext, callback, state);
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:28,代码来源:ExecutionContext.cs


注:本文中的System.Threading.ExecutionContext.IsDefaultFTContext方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。