4 instantiations of ExecutionContext
System.Private.CoreLib (4)
src\runtime\src\libraries\System.Private.CoreLib\src\System\Threading\ExecutionContext.cs (4)
22internal static readonly ExecutionContext Default = new ExecutionContext(); 24internal static readonly ExecutionContext DefaultFlowSuppressed = new ExecutionContext(AsyncLocalValueMap.Empty, new IAsyncLocal[0], isFlowSuppressed: true); 110return new ExecutionContext(m_localValues, m_localChangeNotifications, isFlowSuppressed); 548new ExecutionContext(newValues, newChangeNotifications, isFlowSuppressed);
352 references to ExecutionContext
Aspire.Dashboard (7)
Model\ResourceOutgoingPeerResolver.cs (1)
52using (ExecutionContext.SuppressFlow())
Otlp\Storage\SqliteTelemetryRepository.Runtime.cs (1)
151}, ExecutionContext.Capture(), _otlpContext.Logger, _subscriptionMinExecuteInterval);
Otlp\Storage\Subscription.cs (1)
27public Subscription(string name, ResourceKey? resourceKey, SubscriptionType subscriptionType, Func<Task> callback, Action unsubscribe, ExecutionContext? executionContext, ILogger logger, TimeSpan minExecuteInterval)
ServiceClient\DashboardClient.cs (1)
340using (ExecutionContext.SuppressFlow())
Utils\CallbackThrottler.cs (3)
17public CallbackThrottler(string name, ILogger logger, TimeSpan minExecuteInterval, Func<Task> callback, ExecutionContext? executionContext) 33private readonly ExecutionContext? _executionContext; 114ExecutionContext.Restore(_executionContext);
Aspire.Dashboard.Tests (1)
TelemetryRepositoryTests\LogTests.cs (1)
838using (ExecutionContext.SuppressFlow())
AzureFunctionsEndToEnd.Functions (1)
artifacts\obj\AzureFunctionsEndToEnd.Functions\Debug\net8.0\AzureFunctionsEndToEnd.Functions.GlobalUsings.g.cs (1)
9global using ExecutionContext = System.Threading.ExecutionContext;
AzureFunctionsWithDts.Functions (1)
artifacts\obj\AzureFunctionsWithDts.Functions\Debug\net8.0\AzureFunctionsWithDts.Functions.GlobalUsings.g.cs (1)
9global using ExecutionContext = System.Threading.ExecutionContext;
Microsoft.AspNetCore.Components (4)
RenderTree\Renderer.cs (4)
273var executionContext = ExecutionContext.Capture(); 1416private sealed class HotReloadRenderHandler(Renderer renderer, ExecutionContext? executionContext) 1426ExecutionContext.Run(executionContext, static s => ((Renderer)s!).RenderRootComponentsOnHotReload(), renderer);
Microsoft.AspNetCore.Http.Connections (3)
src\aspnetcore\src\Shared\NonCapturingTimer\NonCapturingTimer.cs (3)
24if (!ExecutionContext.IsFlowSuppressed()) 26ExecutionContext.SuppressFlow(); 37ExecutionContext.RestoreFlow();
Microsoft.AspNetCore.Server.Kestrel.Core (4)
Internal\BaseHttpConnectionContext.cs (1)
50public ExecutionContext? InitialExecutionContext { get; set; }
Internal\Http\HttpProtocol.cs (2)
655_context.InitialExecutionContext = ExecutionContext.Capture(); 662ExecutionContext.Restore(_context.InitialExecutionContext);
Internal\Http2\Http2Connection.cs (1)
167_context.InitialExecutionContext = ExecutionContext.Capture();
Microsoft.AspNetCore.SignalR.Client.Core (3)
src\aspnetcore\src\Shared\NonCapturingTimer\NonCapturingTimer.cs (3)
24if (!ExecutionContext.IsFlowSuppressed()) 26ExecutionContext.SuppressFlow(); 37ExecutionContext.RestoreFlow();
Microsoft.AspNetCore.SignalR.StackExchangeRedis (3)
src\aspnetcore\src\Shared\NonCapturingTimer\NonCapturingTimer.cs (3)
24if (!ExecutionContext.IsFlowSuppressed()) 26ExecutionContext.SuppressFlow(); 37ExecutionContext.RestoreFlow();
Microsoft.AspNetCore.TestHost (2)
TestServer.cs (1)
143/// Gets or sets a value that controls if <see cref="ExecutionContext"/> and <see cref="AsyncLocal{T}"/> values are preserved from the client to the server. The default value is <see langword="false" />.
TestServerOptions.cs (1)
19/// Gets or sets a value that controls if <see cref="ExecutionContext"/> and <see cref="AsyncLocal{T}"/> values are preserved from the client to the server. The default value is <see langword="false" />.
Microsoft.CodeAnalysis.Workspaces (2)
Utilities\FlowControlHelper.cs (2)
13=> new(ExecutionContext.IsFlowSuppressed() ? default : ExecutionContext.SuppressFlow());
Microsoft.Extensions.Diagnostics.HealthChecks (3)
src\aspnetcore\src\Shared\NonCapturingTimer\NonCapturingTimer.cs (3)
24if (!ExecutionContext.IsFlowSuppressed()) 26ExecutionContext.SuppressFlow(); 37ExecutionContext.RestoreFlow();
Microsoft.Extensions.FileProviders.Physical (3)
src\runtime\src\libraries\Common\src\Extensions\NonCapturingTimer\NonCapturingTimer.cs (3)
22if (!ExecutionContext.IsFlowSuppressed()) 24ExecutionContext.SuppressFlow(); 35ExecutionContext.RestoreFlow();
Microsoft.Extensions.Http (3)
src\runtime\src\libraries\Common\src\Extensions\NonCapturingTimer\NonCapturingTimer.cs (3)
22if (!ExecutionContext.IsFlowSuppressed()) 24ExecutionContext.SuppressFlow(); 35ExecutionContext.RestoreFlow();
Microsoft.Extensions.ServiceDiscovery (9)
Http\HttpServiceEndpointResolver.cs (3)
85if (!ExecutionContext.IsFlowSuppressed()) 87ExecutionContext.SuppressFlow(); 98ExecutionContext.RestoreFlow();
ServiceEndpointResolver.cs (3)
93if (!ExecutionContext.IsFlowSuppressed()) 95ExecutionContext.SuppressFlow(); 106ExecutionContext.RestoreFlow();
ServiceEndpointWatcher.cs (3)
108if (!ExecutionContext.IsFlowSuppressed()) 110ExecutionContext.SuppressFlow(); 120ExecutionContext.RestoreFlow();
mscorlib (1)
parent\ref\mscorlib.cs (1)
1129[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Threading.ExecutionContext))]
netstandard (1)
netstandard.cs (1)
2078[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Threading.ExecutionContext))]
ScenarioTests.Common.Tests (5)
ScenarioTestTypes.cs (5)
189if (ExecutionContext.IsFlowSuppressed()) 195var ec = ExecutionContext.Capture(); 199var s = ((SendOrPostCallback d, object state, ExecutionContext ec))obj; 200ExecutionContext.Run(s.ec, new ContextCallback(d), s.state);
System.Data.Odbc (3)
src\runtime\src\libraries\Common\src\System\Data\Common\AdapterUtil.Drivers.cs (3)
18if (!ExecutionContext.IsFlowSuppressed()) 20ExecutionContext.SuppressFlow(); 30ExecutionContext.RestoreFlow();
System.IO.Pipelines (6)
System\IO\Pipelines\CompletionData.cs (2)
12public ExecutionContext? ExecutionContext { get; } 15public CompletionData(Action<object?> completion, object? completionState, ExecutionContext? executionContext, SynchronizationContext? synchronizationContext)
System\IO\Pipelines\Pipe.cs (1)
980ExecutionContext.Run(completionData.ExecutionContext, s_executionContextRawCallback, state);
System\IO\Pipelines\PipeAwaitable.cs (3)
91ExecutionContext? executionContext = schedulingContext?.ExecutionContext; 143_schedulingContext.ExecutionContext = ExecutionContext.Capture(); 207public ExecutionContext? ExecutionContext { get; set; }
System.Net.Http (6)
System\Net\Http\SocketsHttpHandler\ConnectionPool\HttpConnectionPool.Http3.cs (1)
735using (ExecutionContext.SuppressFlow())
System\Net\Http\SocketsHttpHandler\Http2Connection.cs (2)
241using (ExecutionContext.SuppressFlow()) 272using (ExecutionContext.SuppressFlow())
System\Net\Http\SocketsHttpHandler\Http3Connection.cs (1)
102using (ExecutionContext.SuppressFlow())
System\Net\Http\SocketsHttpHandler\HttpConnectionPoolManager.cs (2)
109using (ExecutionContext.SuppressFlow()) // Don't capture the current ExecutionContext and its AsyncLocals onto the timer causing them to live forever 208using (ExecutionContext.SuppressFlow())
System.Net.Http.WinHttpHandler (3)
System\Net\Http\WinHttpHandler.cs (3)
110if (!ExecutionContext.IsFlowSuppressed()) 112ExecutionContext.SuppressFlow(); 132ExecutionContext.RestoreFlow();
System.Net.NetworkInformation (18)
System\Net\NetworkInformation\NetworkAddressChange.cs (4)
18private static readonly Dictionary<NetworkAddressChangedEventHandler, ExecutionContext?> s_addressChangedSubscribers = 19new Dictionary<NetworkAddressChangedEventHandler, ExecutionContext?>(); 22private static readonly Dictionary<NetworkAvailabilityChangedEventHandler, ExecutionContext?> s_availabilityChangedSubscribers = 23new Dictionary<NetworkAvailabilityChangedEventHandler, ExecutionContext?>();
System\Net\NetworkInformation\NetworkAddressChange.Unix.cs (14)
63s_addressChangedSubscribers.TryAdd(value, ExecutionContext.Capture()); 109using (ExecutionContext.SuppressFlow()) 115s_availabilityChangedSubscribers.TryAdd(value, ExecutionContext.Capture()); 171using (ExecutionContext.SuppressFlow()) 266Dictionary<NetworkAddressChangedEventHandler, ExecutionContext?>? addressChangedSubscribers = null; 272addressChangedSubscribers = new Dictionary<NetworkAddressChangedEventHandler, ExecutionContext?>(s_addressChangedSubscribers); 278foreach (KeyValuePair<NetworkAddressChangedEventHandler, ExecutionContext?> 282ExecutionContext? ec = subscriber.Value; 290ExecutionContext.Run(ec, s_runAddressChangedHandler, handler); 298Dictionary<NetworkAvailabilityChangedEventHandler, ExecutionContext?>? availabilityChangedSubscribers = null; 308new Dictionary<NetworkAvailabilityChangedEventHandler, ExecutionContext?>( 320foreach (KeyValuePair<NetworkAvailabilityChangedEventHandler, ExecutionContext?> 324ExecutionContext? ec = subscriber.Value; 332ExecutionContext.Run(ec, callbackContext, handler);
System.Net.Requests (12)
src\runtime\src\libraries\Common\src\System\Net\ContextAwareResult.cs (12)
24private readonly ExecutionContext? _savedContext; 26internal CallbackClosure(ExecutionContext context, AsyncCallback? callback) 60internal ExecutionContext? Context 85private volatile ExecutionContext? _context; 127internal ExecutionContext? ContextCopy 137ExecutionContext? context = _context; 205ExecutionContext? cachedContext = null; 223ExecutionContext? cachedContext; 268private bool CaptureOrComplete(ref ExecutionContext? cachedContext, bool returnContext) 290cachedContext ??= ExecutionContext.Capture(); 350ExecutionContext? context = _context; 361ExecutionContext.Run(context, s => ((ContextAwareResult)s!).CompleteCallback(), this);
System.Net.Sockets (6)
System\Net\Sockets\SocketAsyncEventArgs.cs (6)
73private ExecutionContext? _context; 568_context = ExecutionContext.Capture(); 665ExecutionContext? context = _context; // store context before it's cleared as part of finishing the operation 675ExecutionContext.Run(context, s_executionCallback, this); 1131ExecutionContext? context = _context; // store context before it's cleared as part of finishing the operation 1142ExecutionContext.Run(context, s_executionCallback, this);
System.Private.CoreLib (182)
src\runtime\src\coreclr\System.Private.CoreLib\src\System\Runtime\CompilerServices\AsyncHelpers.CoreCLR.cs (34)
111public unsafe bool TryGetExecutionContext(out ExecutionContext? execContext) 123execContext = Unsafe.As<byte, ExecutionContext?>(ref Unsafe.Add(ref data, (DataOffset - PointerSize) + index * PointerSize)); 231public ExecutionContext? LeafExecutionContext; 290private ExecutionContext? _executionContext; 307ExecutionContext? currentExecutionCtx = thread._executionContext; 310ExecutionContext.RestoreChangedContextToThread(thread, _executionContext, currentExecutionCtx); 794ExecutionContext? suspendingExecutionContext = stackState->LeafExecutionContext; 974if (curContinuation.TryGetExecutionContext(out ExecutionContext? execContext)) 1097if (curContinuation.TryGetExecutionContext(out ExecutionContext? execContext)) 1387private static ExecutionContext? CaptureExecutionContext() 1389return ExecutionContext.CaptureForSuspension(Thread.CurrentThreadAssumedInitialized); 1393private static void RestoreExecutionContext(Thread thread, ExecutionContext? previousExecCtx) 1395ExecutionContext? currentExecCtx = thread._executionContext; 1396if (previousExecCtx != currentExecCtx && previousExecCtx != ExecutionContext.DefaultFlowSuppressed) 1398ExecutionContext.RestoreChangedContextToThread(thread, previousExecCtx, currentExecCtx); 1403private static void CaptureContexts(out Thread thread, out ExecutionContext? execCtx, out SynchronizationContext? syncCtx) 1416private static void RestoreContexts(bool resumed, Thread thread, ExecutionContext? previousExecCtx, SynchronizationContext? previousSyncCtx) 1425ExecutionContext? currentExecCtx = thread._executionContext; 1428ExecutionContext.RestoreChangedContextToThread(thread, previousExecCtx, currentExecCtx); 1438private static void RestoreContextsOnSuspension(bool resumed, ExecutionContext? previousExecCtx, SynchronizationContext? previousSyncCtx) 1514private static void RestoreInlinedFrameContexts(ExecutionContext? previousExecCtx, object? continuationContext, ContinuationFlags flags) 1617ref ExecutionContext? execContext) 1634ref ExecutionContext? execContext) 1650ref ExecutionContext? execContext) 1664private static void FinishSuspensionNoContinuationContext(ref ExecutionContext? execCtx, bool resumed, ExecutionContext? previousExecCtx, SynchronizationContext? previousSyncCtx) 1668ExecutionContext? threadExecCtx = thread._executionContext; 1676execCtx = ExecutionContext.DefaultFlowSuppressed; 1685Debug.Assert(threadExecCtx == null || !threadExecCtx.InstanceIsFlowSuppressed || execCtx == ExecutionContext.DefaultFlowSuppressed); 1706private static void FinishSuspensionWithContinuationContext(ref object continuationContext, ref ContinuationFlags flags, ref ExecutionContext? execCtx, bool resumed, ExecutionContext? previousExecCtx, SynchronizationContext? previousSyncCtx) 1735ExecutionContext? threadExecCtx = thread._executionContext; 1742execCtx = ExecutionContext.DefaultFlowSuppressed; 1751Debug.Assert(threadExecCtx == null || !threadExecCtx.InstanceIsFlowSuppressed || execCtx == ExecutionContext.DefaultFlowSuppressed);
src\runtime\src\libraries\Common\src\System\TimeProvider.cs (2)
156/// <see cref="CreateTimer"/> captures the <see cref="ExecutionContext"/> and stores that with the <see cref="ITimer"/> for use in invoking <paramref name="callback"/> 157/// each time it's called. That capture can be suppressed with <see cref="ExecutionContext.SuppressFlow"/>.
src\runtime\src\libraries\System.Private.CoreLib\src\Microsoft\Win32\SafeHandles\SafeFileHandle.ThreadPoolValueTaskSource.cs (3)
35private ExecutionContext? _context; 161ExecutionContext.RunForThreadPoolUnsafe(_context, static x => x.ExecuteInternal(), this); 167_context = ExecutionContext.Capture();
src\runtime\src\libraries\System.Private.CoreLib\src\System\IO\Stream.cs (4)
647private ExecutionContext? _context; 681_context = ExecutionContext.Capture(); 703ExecutionContext? context = _context; 717ExecutionContext.RunInternal(context, invokeAsyncCallback, this);
src\runtime\src\libraries\System.Private.CoreLib\src\System\Runtime\CompilerServices\AsyncIteratorMethodBuilder.cs (1)
26/// <summary>Invokes <see cref="IAsyncStateMachine.MoveNext"/> on the state machine while guarding the <see cref="ExecutionContext"/>.</summary>
src\runtime\src\libraries\System.Private.CoreLib\src\System\Runtime\CompilerServices\AsyncMethodBuilderCore.cs (3)
33ExecutionContext? previousExecutionCtx = currentThread._executionContext; 49ExecutionContext? currentExecutionCtx = currentThread._executionContext; 52ExecutionContext.RestoreChangedContextToThread(currentThread, previousExecutionCtx, currentExecutionCtx);
src\runtime\src\libraries\System.Private.CoreLib\src\System\Runtime\CompilerServices\AsyncTaskMethodBuilderT.cs (9)
175ExecutionContext? currentContext = ExecutionContext.CaptureForSuspension(Thread.CurrentThread); 474public ref ExecutionContext? Context 478Debug.Assert(m_stateObject is null or ExecutionContext, $"Expected {nameof(m_stateObject)} to be null or an ExecutionContext but was {(m_stateObject is object o ? o.GetType().ToString() : "(null)")}."); 479return ref Unsafe.As<object?, ExecutionContext?>(ref m_stateObject); 519ExecutionContext? context = Context; 520if (context == ExecutionContext.DefaultFlowSuppressed) 529ExecutionContext.RunInternal(context, s_callback, this); 533ExecutionContext.RunFromThreadPoolDispatchLoop(threadPoolThread, context, s_callback, this);
src\runtime\src\libraries\System.Private.CoreLib\src\System\Runtime\CompilerServices\PoolingAsyncValueTaskMethodBuilderT.cs (6)
166ExecutionContext? currentContext = ExecutionContext.CaptureForSuspension(Thread.CurrentThread); 251public ExecutionContext? Context; 441ExecutionContext? context = Context; 443if (context == ExecutionContext.DefaultFlowSuppressed) 450ExecutionContext.RunInternal(context, s_callback, this);
src\runtime\src\libraries\System.Private.CoreLib\src\System\Threading\AsyncLocal.cs (2)
37object? value = ExecutionContext.GetLocalValue(this); 47ExecutionContext.SetLocalValue(this, value, _valueChangedHandler is not null);
src\runtime\src\libraries\System.Private.CoreLib\src\System\Threading\CancellationToken.cs (8)
125/// The current <see cref="ExecutionContext">ExecutionContext</see>, if one exists, will be captured 146/// The current <see cref="ExecutionContext">ExecutionContext</see>, if one exists, will be captured 178/// The current <see cref="ExecutionContext">ExecutionContext</see>, if one exists, will be captured 193/// generates will be propagated out of this method call. The current <see cref="ExecutionContext">ExecutionContext</see>, if one exists, 214/// The current <see cref="ExecutionContext">ExecutionContext</see>, if one exists, 241/// <see cref="ExecutionContext">ExecutionContext</see> is not captured nor flowed 256/// generates will be propagated out of this method call. <see cref="ExecutionContext"/> is not captured nor flowed to the callback's invocation. 293source.Register(callback, state, useSynchronizationContext ? SynchronizationContext.Current : null, useExecutionContext ? ExecutionContext.Capture() : null) :
src\runtime\src\libraries\System.Private.CoreLib\src\System\Threading\CancellationTokenSource.cs (8)
218using (ExecutionContext.SuppressFlow()) 243/// The <see cref="ExecutionContext"/> that was captured when each callback was registered 268/// The <see cref="ExecutionContext"/> that was captured when each callback was registered 300/// The <see cref="ExecutionContext"/> that was captured when each callback was registered 587Delegate callback, object? stateForCallback, SynchronizationContext? syncContext, ExecutionContext? executionContext) 1190public ExecutionContext? ExecutionContext; 1201ExecutionContext? context = ExecutionContext; 1209ExecutionContext.RunInternal(context, static s =>
src\runtime\src\libraries\System.Private.CoreLib\src\System\Threading\ExecutionContext.cs (32)
22internal static readonly ExecutionContext Default = new ExecutionContext(); 24internal static readonly ExecutionContext DefaultFlowSuppressed = new ExecutionContext(AsyncLocalValueMap.Empty, new IAsyncLocal[0], isFlowSuppressed: true); 54public static ExecutionContext? Capture() 56ExecutionContext? executionContext = Thread.CurrentThread._executionContext; 70internal static ExecutionContext? CaptureForRestore() 86internal static ExecutionContext? CaptureForSuspension(Thread currentThread) 90ExecutionContext? executionContext = currentThread._executionContext; 99private ExecutionContext? ShallowClone(bool isFlowSuppressed) 116ExecutionContext? executionContext = currentThread._executionContext ?? Default; 131ExecutionContext? executionContext = currentThread._executionContext; 142ExecutionContext? executionContext = Thread.CurrentThread._executionContext; 152public static void Run(ExecutionContext executionContext, ContextCallback callback, object? state) 163internal static void RunInternal(ExecutionContext? executionContext, ContextCallback callback, object? state) 172ExecutionContext? previousExecutionCtx0 = currentThread._executionContext; 179ExecutionContext? previousExecutionCtx = previousExecutionCtx0; 213ExecutionContext? currentExecutionCtx = currentThread._executionContext; 232public static void Restore(ExecutionContext executionContext) 242internal static void RestoreInternal(ExecutionContext? executionContext) 246ExecutionContext? currentExecutionCtx = currentThread._executionContext; 265internal static void RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext? executionContext, ContextCallback callback, object state) 294ExecutionContext? currentExecutionCtx = currentThread._executionContext; 309internal static void RunForThreadPoolUnsafe<TState>(ExecutionContext executionContext, Action<TState> callback, in TState state) 329internal static void RestoreChangedContextToThread(Thread currentThread, ExecutionContext? contextToRestore, ExecutionContext? currentContext) 348ExecutionContext? currentExecutionCtx = currentThread._executionContext; 372internal static void OnValuesChanged(ExecutionContext? previousExecutionCtx, ExecutionContext? nextExecutionCtx) 467ExecutionContext? current = Thread.CurrentThread._executionContext; 481ExecutionContext? current = Thread.CurrentThread._executionContext; 556public ExecutionContext CreateCopy() 599if (!ExecutionContext.IsFlowSuppressed()) 605ExecutionContext.RestoreFlow();
src\runtime\src\libraries\System.Private.CoreLib\src\System\Threading\IOCompletionCallbackHelper.cs (3)
13private readonly ExecutionContext _executionContext; 18public IOCompletionCallbackHelper(IOCompletionCallback ioCompletionCallback, ExecutionContext executionContext) 58ExecutionContext.RunInternal(helper._executionContext, IOCompletionCallback_Context_Delegate, helper);
src\runtime\src\libraries\System.Private.CoreLib\src\System\Threading\Overlapped.cs (2)
84ExecutionContext? ec = ExecutionContext.Capture();
src\runtime\src\libraries\System.Private.CoreLib\src\System\Threading\PeriodicTimer.cs (1)
73using (ExecutionContext.SuppressFlow())
src\runtime\src\libraries\System.Private.CoreLib\src\System\Threading\Tasks\Sources\ManualResetValueTaskSourceCore.cs (16)
147_capturedContext = ExecutionContext.Capture(); 157new CapturedSchedulerAndExecutionContext(sc, (ExecutionContext)_capturedContext); 166new CapturedSchedulerAndExecutionContext(ts, (ExecutionContext)_capturedContext); 207case ExecutionContext: 255else if (context is ExecutionContext or CapturedSchedulerAndExecutionContext) 272internal readonly ExecutionContext _executionContext; 274public CapturedSchedulerAndExecutionContext(object scheduler, ExecutionContext executionContext) 337Debug.Assert(capturedContext is ExecutionContext or CapturedSchedulerAndExecutionContext, $"{nameof(capturedContext)} is {capturedContext}"); 340ExecutionContext? currentContext = ExecutionContext.CaptureForRestore(); 342if (capturedContext is ExecutionContext ec) 344ExecutionContext.RestoreInternal(ec); // Restore the captured ExecutionContext before executing anything. 353ExecutionContext.RestoreInternal(currentContext); // Restore the current ExecutionContext. 378ExecutionContext.RestoreInternal(currentContext); 388ExecutionContext.Restore(cc._executionContext); // Restore the captured ExecutionContext before executing anything. 395ExecutionContext.RestoreInternal(currentContext); // Restore the current ExecutionContext.
src\runtime\src\libraries\System.Private.CoreLib\src\System\Threading\Tasks\Task.cs (10)
366internal ExecutionContext? m_capturedContext; // The execution context to run the task within, if any. Only set from non-concurrent contexts. 669CapturedContext = ExecutionContext.Capture(); 1684internal ExecutionContext? CapturedContext 1694return m_contingentProperties?.m_capturedContext ?? ExecutionContext.Default; 1704else if (value != ExecutionContext.Default) // not the default context, then inflate the contingent properties and set it 2485ExecutionContext? ec = CapturedContext; 2496ExecutionContext.RunInternal(ec, s_ecCallback, this); 2500ExecutionContext.RunFromThreadPoolDispatchLoop(threadPoolThread, ec, s_ecCallback, this); 3043using (ExecutionContext.SuppressFlow()) 5981using (ExecutionContext.SuppressFlow())
src\runtime\src\libraries\System.Private.CoreLib\src\System\Threading\Tasks\TaskContinuation.cs (9)
491internal static void RunOrScheduleAction(Action action, TaskScheduler scheduler, ExecutionContext? capturedContext, bool allowInlining) 536protected readonly ExecutionContext? m_capturedContext; 551m_capturedContext = ExecutionContext.Capture(); 561protected static Task CreateTask(Action<object?> action, object? state, TaskScheduler scheduler, ExecutionContext? capturedContext) 637ExecutionContext? context = m_capturedContext; 656ExecutionContext.CheckThreadPoolAndContextsAreDefault(); 666ExecutionContext.RunForThreadPoolUnsafe(context, s_invokeAction, m_action); 707ExecutionContext? context = m_capturedContext; 716ExecutionContext.RunInternal(context, callback, state);
src\runtime\src\libraries\System.Private.CoreLib\src\System\Threading\Thread.cs (6)
33internal ExecutionContext? _executionContext; 53ExecutionContext.RunInternal(_executionContext, s_threadStartContextCallback, this); 213startHelper._executionContext = captureContext ? ExecutionContext.Capture() : null; 249startHelper._executionContext = captureContext ? ExecutionContext.Capture() : null; 397public ExecutionContext? ExecutionContext => ExecutionContext.Capture();
src\runtime\src\libraries\System.Private.CoreLib\src\System\Threading\ThreadPoolWorkQueue.cs (17)
1015ExecutionContext.ResetThreadPoolThread(currentThread); 1188private readonly ExecutionContext _context; 1199internal QueueUserWorkItemCallback(WaitCallback callback, object? state, ExecutionContext context) 1212ExecutionContext.RunForThreadPoolUnsafe(_context, s_executionContextShim, this); 1220private readonly ExecutionContext _context; 1222internal QueueUserWorkItemCallback(Action<TState> callback, TState state, ExecutionContext context) 1239ExecutionContext.RunForThreadPoolUnsafe(_context, callback, in _state); 1258ExecutionContext.CheckThreadPoolAndContextsAreDefault(); 1286ExecutionContext.CheckThreadPoolAndContextsAreDefault(); 1302private readonly ExecutionContext? _executionContext; 1315_executionContext = ExecutionContext.Capture(); 1336ExecutionContext? context = helper._executionContext; 1344ExecutionContext.Run(context, timedOut ? _ccbt : _ccbf, helper); 1546ExecutionContext? context = ExecutionContext.Capture(); 1564ExecutionContext? context = ExecutionContext.Capture();
src\runtime\src\libraries\System.Private.CoreLib\src\System\Threading\Timer.cs (5)
469private readonly ExecutionContext? _executionContext; 503_executionContext = ExecutionContext.Capture(); 711ExecutionContext? context = _executionContext; 720ExecutionContext.RunFromThreadPoolDispatchLoop(Thread.CurrentThread, context, s_callCallbackInContext, this); 724ExecutionContext.RunInternal(context, s_callCallbackInContext, this);
System\Threading\Thread.NativeAot.cs (1)
28internal ExecutionContext? _executionContext;
System.Runtime.Caching (6)
System\Runtime\Caching\CacheExpires.cs (3)
851if (!ExecutionContext.IsFlowSuppressed()) 853ExecutionContext.SuppressFlow(); 864ExecutionContext.RestoreFlow();
System\Runtime\Caching\MemoryCacheStatistics.cs (3)
176if (!ExecutionContext.IsFlowSuppressed()) 178ExecutionContext.SuppressFlow(); 188ExecutionContext.RestoreFlow();
System.Security.Principal.Windows (3)
System\Security\Principal\WindowsIdentity.cs (3)
771ExecutionContext? currentContext = ExecutionContext.Capture(); 775ExecutionContext.Run(
System.ServiceModel.NetTcp (11)
System\ServiceModel\Channels\SocketConnection.cs (11)
200if (!ExecutionContext.IsFlowSuppressed()) 202ExecutionContext.SuppressFlow(); 210ExecutionContext.RestoreFlow(); 237ExecutionContext.RestoreFlow(); 283if (!ExecutionContext.IsFlowSuppressed()) 285ExecutionContext.SuppressFlow(); 295ExecutionContext.RestoreFlow(); 324ExecutionContext.RestoreFlow(); 766if (!ExecutionContext.IsFlowSuppressed()) 768ExecutionContext.SuppressFlow(); 779ExecutionContext.RestoreFlow();
System.ServiceModel.UnixDomainSocket (11)
System\ServiceModel\Channels\SocketConnection.cs (11)
182if (!ExecutionContext.IsFlowSuppressed()) 184ExecutionContext.SuppressFlow(); 192ExecutionContext.RestoreFlow(); 219ExecutionContext.RestoreFlow(); 264if (!ExecutionContext.IsFlowSuppressed()) 266ExecutionContext.SuppressFlow(); 274ExecutionContext.RestoreFlow(); 303ExecutionContext.RestoreFlow(); 730if (!ExecutionContext.IsFlowSuppressed()) 732ExecutionContext.SuppressFlow(); 743ExecutionContext.RestoreFlow();
System.Threading (6)
src\runtime\artifacts\obj\System.Threading\Release\net11.0\System.Threading.Forwards.cs (1)
11[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Threading.ExecutionContext))]
System\Threading\Barrier.cs (3)
136private readonly ExecutionContext? _ownerThreadContext; 233_ownerThreadContext = ExecutionContext.Capture(); 793ExecutionContext.Run(_ownerThreadContext, handler, this);
System\Threading\HostExecutionContextManager.cs (2)
9/// Normally, the current <see cref="HostExecutionContext"/> would be stored on the <see cref="ExecutionContext"/>. 11/// separating itself from the <see cref="ExecutionContext"/> to minimize unnecessary additions there.
System.Threading.Channels (10)
System\Threading\Channels\AsyncOperation.cs (10)
217if (ctx is null or ExecutionContext) 273ExecutionContext? ec = 275ctx as ExecutionContext ?? 288ExecutionContext.Run(ec, static s => 326_capturedContext = ExecutionContext.Capture(); 339new CapturedSchedulerAndExecutionContext(sc, (ExecutionContext)_capturedContext); 349new CapturedSchedulerAndExecutionContext(ts, (ExecutionContext)_capturedContext); 408Debug.Assert(capturedContext is ExecutionContext); 417internal readonly ExecutionContext _executionContext; 419public CapturedSchedulerAndExecutionContext(object scheduler, ExecutionContext executionContext)
System.Threading.RateLimiting (3)
System\Threading\RateLimiting\TimerAwaitable.cs (3)
49if (!ExecutionContext.IsFlowSuppressed()) 51ExecutionContext.SuppressFlow(); 69ExecutionContext.RestoreFlow();
System.Threading.Tasks.Parallel (5)
System\Threading\Tasks\Parallel.ForEachAsync.cs (5)
522/// <summary>The <see cref="ExecutionContext"/> present at the time of the ForEachAsync invocation. This is only used if on the default scheduler.</summary> 523private readonly ExecutionContext? _executionContext; 549_executionContext = ExecutionContext.Capture(); 668/// <summary>Executes the task body using the <see cref="ExecutionContext"/> captured when ForEachAsync was invoked.</summary> 679ExecutionContext.Run(_executionContext, static o => ((ForEachAsyncState<TSource>)o!)._taskBody(o), this);
System.Windows.Forms (5)
System\Windows\Forms\Control.cs (3)
6335ExecutionContext.Run(tme._executionContext, s_invokeMarshaledCallbackHelperDelegate, tme); 6738ExecutionContext? executionContext = null; 6741executionContext = ExecutionContext.Capture();
System\Windows\Forms\Control.ThreadMethodEntry.cs (2)
25internal ExecutionContext? _executionContext; 37ExecutionContext? executionContext)