4 instantiations of ExecutionContext
System.Private.CoreLib (4)
352 references to ExecutionContext
Aspire.Dashboard (7)
Aspire.Dashboard.Tests (1)
AzureFunctionsEndToEnd.Functions (1)
AzureFunctionsWithDts.Functions (1)
Microsoft.AspNetCore.Components (4)
Microsoft.AspNetCore.Http.Connections (3)
Microsoft.AspNetCore.Server.Kestrel.Core (4)
Microsoft.AspNetCore.SignalR.Client.Core (3)
Microsoft.AspNetCore.SignalR.StackExchangeRedis (3)
Microsoft.AspNetCore.TestHost (2)
Microsoft.CodeAnalysis.Workspaces (2)
Microsoft.Extensions.Diagnostics.HealthChecks (3)
Microsoft.Extensions.FileProviders.Physical (3)
Microsoft.Extensions.Http (3)
Microsoft.Extensions.ServiceDiscovery (9)
mscorlib (1)
netstandard (1)
ScenarioTests.Common.Tests (5)
System.Data.Odbc (3)
System.IO.Pipelines (6)
System.Net.Http (6)
System.Net.Http.WinHttpHandler (3)
System.Net.NetworkInformation (18)
System.Net.Requests (12)
System.Net.Sockets (6)
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\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\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\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\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();
System.Runtime.Caching (6)
System.Security.Principal.Windows (3)
System.ServiceModel.NetTcp (11)
System.ServiceModel.UnixDomainSocket (11)
System.Threading (6)
System.Threading.Channels (10)
System.Threading.RateLimiting (3)
System.Threading.Tasks.Parallel (5)
System.Windows.Forms (5)