當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。