本文整理汇总了C#中System.Threading.ExecutionContext类的典型用法代码示例。如果您正苦于以下问题:C# ExecutionContext类的具体用法?C# ExecutionContext怎么用?C# ExecutionContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ExecutionContext类属于System.Threading命名空间,在下文中一共展示了ExecutionContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Setup
internal void Setup()
{
this.useEC = true;
this._ec = Thread.CurrentThread.ExecutionContext;
this._ec.isFlowSuppressed = true;
this._thread = Thread.CurrentThread;
}
示例2: ExecutionContext
internal ExecutionContext (ExecutionContext ec)
{
if (ec._sc != null)
_sc = new SecurityContext (ec._sc);
_suppressFlow = ec._suppressFlow;
_capture = true;
}
示例3: AsyncResult
internal AsyncResult (WaitCallback cb, object state, bool capture_context)
{
async_state = state;
async_delegate = cb;
if (capture_context)
current = ExecutionContext.Capture ();
}
示例4: CimAsyncCallbacksReceiverBase
protected CimAsyncCallbacksReceiverBase()
{
this._operationLock = new object();
this._operationPendingActions = new List<Action<CimOperation>>();
this._suppressFurtherUserCallbacksLock = new object();
this._threadExecutionContext = ExecutionContext.Capture();
}
示例5: _IOCompletionCallback
internal _IOCompletionCallback(IOCompletionCallback ioCompletionCallback, ref StackCrawlMark stackMark)
{
_ioCompletionCallback = ioCompletionCallback;
// clone the exection context
_executionContext = ExecutionContext.Capture(ref stackMark);
ExecutionContext.ClearSyncContext(_executionContext);
}
示例6: Capture
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;
}
示例7: Undo
public void Undo()
{
if (this.currEC != null)
{
if (this.currEC != Thread.CurrentThread.GetExecutionContextNoCreate())
{
Environment.FailFast(Environment.GetResourceString("InvalidOperation_SwitcherCtxMismatch"));
}
if (this.currSC != this.currEC.SecurityContext)
{
Environment.FailFast(Environment.GetResourceString("InvalidOperation_SwitcherCtxMismatch"));
}
this.currEC.SecurityContext = this.prevSC;
this.currEC = null;
bool flag = true;
try
{
if (this.wic != null)
{
flag &= this.wic.UndoNoThrow();
}
}
catch
{
flag &= this.cssw.UndoNoThrow();
Environment.FailFast(Environment.GetResourceString("ExecutionContext_UndoFailed"));
}
if (!(flag & this.cssw.UndoNoThrow()))
{
Environment.FailFast(Environment.GetResourceString("ExecutionContext_UndoFailed"));
}
}
}
示例8: WrapResultDelegate
static ResultDelegate WrapResultDelegate(ExecutionContext context, ResultDelegate result)
{
return (status, headers, body) => result(
status,
headers,
WrapBodyDelegate(context, body));
}
示例9: TlsStream
//
// This version of an Ssl Stream is for internal HttpWebrequest use.
// This Ssl client owns the underlined socket
// The TlsStream will own secured read/write and disposal of the passed "networkStream" stream.
//
public TlsStream(string destinationHost, NetworkStream networkStream, X509CertificateCollection clientCertificates, ServicePoint servicePoint, object initiatingRequest, ExecutionContext executionContext)
:base(networkStream, true) {
// WebRequest manages the execution context manually so we have to ensure we get one for SSL client certificate demand
_ExecutionContext = executionContext;
if (_ExecutionContext == null)
{
_ExecutionContext = ExecutionContext.Capture();
}
//
GlobalLog.Enter("TlsStream::TlsStream", "host="+destinationHost+", #certs="+((clientCertificates == null) ? "none" : clientCertificates.Count.ToString(NumberFormatInfo.InvariantInfo)));
if (Logging.On) Logging.PrintInfo(Logging.Web, this, ".ctor", "host="+destinationHost+", #certs="+((clientCertificates == null) ? "null" : clientCertificates.Count.ToString(NumberFormatInfo.InvariantInfo)));
m_ExceptionStatus = WebExceptionStatus.SecureChannelFailure;
m_Worker = new SslState(networkStream, initiatingRequest is HttpWebRequest, SettingsSectionInternal.Section.EncryptionPolicy);
m_DestinationHost = destinationHost;
m_ClientCertificates = clientCertificates;
RemoteCertValidationCallback certValidationCallback = servicePoint.SetupHandshakeDoneProcedure(this, initiatingRequest);
m_Worker.SetCertValidationDelegate(certValidationCallback);
// The Handshake is NOT done at this point
GlobalLog.Leave("TlsStream::TlsStream (Handshake is not done)");
}
示例10: SynchronizationContextSwitcher
public SynchronizationContextSwitcher(SynchronizationContext context)
{
_newContext = context;
_executionContext = Thread.CurrentThread.ExecutionContext;
_oldContext = SynchronizationContext.Current;
SynchronizationContext.SetSynchronizationContext(context);
}
示例11: WorkItem
public WorkItem(WorkItemId taskID, WaitCallback wc, IAsyncResult state, ExecutionContext ctx)
{
_callback = wc;
_state = state;
_ctx = ctx;
_taskID = taskID;
}
示例12: WrapBodyDelegate
static BodyDelegate WrapBodyDelegate(ExecutionContext context, BodyDelegate body)
{
return body == null ? (BodyDelegate)null : (write, flush, end, cancellationToken) => ExecutionContext.Run(
context.CreateCopy(),
_ => body(write, WrapFlushDelegate(context, flush), end, cancellationToken),
null);
}
示例13: ClearSyncContext
internal static void ClearSyncContext(ExecutionContext ec)
{
if (ec != null)
{
ec.SynchronizationContext = null;
}
}
示例14: CancellationCallbackInfo
internal CancellationCallbackInfo(Action<object> callback, object stateForCallback, SynchronizationContext targetSyncContext, ExecutionContext targetExecutionContext, System.Threading.CancellationTokenSource cancellationTokenSource)
{
this.Callback = callback;
this.StateForCallback = stateForCallback;
this.TargetSyncContext = targetSyncContext;
this.TargetExecutionContext = targetExecutionContext;
this.CancellationTokenSource = cancellationTokenSource;
}
示例15: CancellationCallbackInfo
internal CancellationCallbackInfo(Action<object> callback, object stateForCallback, SynchronizationContext targetSyncContext, ExecutionContext targetExecutionContext, CancellationTokenSource cancellationTokenSource)
{
Callback = callback;
StateForCallback = stateForCallback;
TargetSyncContext = targetSyncContext;
TargetExecutionContext = targetExecutionContext;
CancellationTokenSource = cancellationTokenSource;
}