本文整理汇总了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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}