58 instantiations of AsyncLocal
aspire (1)
Utils\NpmInstallDetection.cs (1)
28private static readonly AsyncLocal<IEnvironmentReader?> s_environmentOverride = new();
Aspire.Dashboard.Tests (2)
ResourceOutgoingPeerResolverTests.cs (1)
375var ambientValue = new AsyncLocal<string?> { Value = "request" };
TelemetryRepositoryTests\LogTests.cs (1)
824var asyncLocal = new AsyncLocal<string>();
Aspire.Hosting (2)
InteractionService.cs (1)
25private static readonly AsyncLocal<bool> s_nonInteractiveScope = new();
Pipelines\PipelineLoggerProvider.cs (1)
18private static readonly AsyncLocal<StepLoggerHolder?> s_currentStep = new();
Aspire.Hosting.Maui (1)
Lifecycle\MauiBuildQueueEventSubscriber.cs (1)
40private readonly AsyncLocal<bool> _isLaunchTimeoutStop = new();
Aspire.Hosting.Native.Client (1)
NativeProviderDefinition.cs (1)
46private readonly AsyncLocal<NativeClient.ProviderInvocation?> _invocation = new();
Aspire.Hosting.Testing (1)
DistributedApplicationEntryPointInvoker.cs (1)
94private static readonly AsyncLocal<EntryPointInvoker> s_currentListener = new();
GenerateDocumentationAndConfigFiles (1)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Log\RoslynTelemetry.cs (1)
20private static readonly AsyncLocal<RoslynTelemetry?> s_current = new();
GetDocument.Insider (1)
src\dc0dd7c6a4fbfb95\HostFactoryResolver.cs (1)
209private static readonly AsyncLocal<HostingListener> _currentListener = new();
Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore (1)
DatabaseErrorPageMiddleware.cs (1)
24private static readonly AsyncLocal<DiagnosticHolder> _localDiagnostic = new AsyncLocal<DiagnosticHolder>();
Microsoft.AspNetCore.HeaderPropagation (1)
HeaderPropagationValues.cs (1)
13private static readonly AsyncLocal<IDictionary<string, StringValues>?> _headers = new AsyncLocal<IDictionary<string, StringValues>?>();
Microsoft.AspNetCore.Http (1)
HttpContextAccessor.cs (1)
14private static readonly AsyncLocal<HttpContextHolder> _httpContextCurrent = new AsyncLocal<HttpContextHolder>();
Microsoft.AspNetCore.InternalTesting (1)
RepeatContext.cs (1)
10private static readonly AsyncLocal<RepeatContext> _current = new AsyncLocal<RepeatContext>();
Microsoft.AspNetCore.Mvc.Core (1)
Infrastructure\ActionContextAccessor.cs (1)
19private static readonly AsyncLocal<ActionContext> _storage = new AsyncLocal<ActionContext>();
Microsoft.AspNetCore.Mvc.Testing (1)
src\dc0dd7c6a4fbfb95\HostFactoryResolver.cs (1)
209private static readonly AsyncLocal<HostingListener> _currentListener = new();
Microsoft.AspNetCore.TestHost (1)
src\dc0dd7c6a4fbfb95\HostFactoryResolver.cs (1)
209private static readonly AsyncLocal<HostingListener> _currentListener = new();
Microsoft.Build (1)
ElementLocation\XmlDocumentWithLocation.cs (1)
59private readonly AsyncLocal<ElementLocation> _elementLocation = new AsyncLocal<ElementLocation>();
Microsoft.Build.Framework (1)
FileUtilities.cs (1)
47private static readonly AsyncLocal<string?> s_currentThreadWorkingDirectory = new();
Microsoft.CodeAnalysis.Analyzers (1)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Log\RoslynTelemetry.cs (1)
20private static readonly AsyncLocal<RoslynTelemetry?> s_current = new();
Microsoft.CodeAnalysis.AnalyzerUtilities (1)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Log\RoslynTelemetry.cs (1)
20private static readonly AsyncLocal<RoslynTelemetry?> s_current = new();
Microsoft.CodeAnalysis.CodeStyle (1)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Log\RoslynTelemetry.cs (1)
20private static readonly AsyncLocal<RoslynTelemetry?> s_current = new();
Microsoft.CodeAnalysis.NetAnalyzers (1)
src\9382845807600969\AnalysisEntityDataFlowOperationVisitor.cs (1)
1189internal static readonly AsyncLocal<Action<object, AnalysisEntityDataFlowScanKind, IOperation>?> Observer = new();
Microsoft.CodeAnalysis.ResxSourceGenerator (1)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Log\RoslynTelemetry.cs (1)
20private static readonly AsyncLocal<RoslynTelemetry?> s_current = new();
Microsoft.CodeAnalysis.Workspaces (1)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Log\RoslynTelemetry.cs (1)
20private static readonly AsyncLocal<RoslynTelemetry?> s_current = new();
Microsoft.Extensions.AI (2)
ChatCompletion\FunctionInvokingChatClient.cs (1)
70private static readonly AsyncLocal<FunctionInvocationContext?> _currentContext = new();
Realtime\FunctionInvokingRealtimeClientSession.cs (1)
58private static readonly AsyncLocal<FunctionInvocationContext?> _currentContext = new();
Microsoft.Extensions.AI.Tests (5)
ChatCompletion\UseDelegateChatClientTests.cs (4)
32AsyncLocal<int> asyncLocal = new(); 81AsyncLocal<int> asyncLocal = new(); 123AsyncLocal<int> asyncLocal = new(); 174AsyncLocal<int> asyncLocal = new();
Embeddings\UseDelegateEmbeddingGeneratorTests.cs (1)
31AsyncLocal<int> asyncLocal = new();
Microsoft.Extensions.AsyncState (1)
AsyncState.cs (1)
15private static readonly AsyncLocal<AsyncStateHolder> _asyncContextCurrent = new();
Microsoft.Extensions.Caching.Memory (1)
CacheEntry.cs (1)
18private static readonly AsyncLocal<CacheEntry?> _current = new AsyncLocal<CacheEntry?>();
Microsoft.Extensions.Http.Diagnostics (2)
Latency\Internal\HttpClientLatencyContext.cs (1)
11private readonly AsyncLocal<ILatencyContext?> _latencyContext = new();
Logging\Internal\OutgoingRequestContext.cs (1)
11private static readonly AsyncLocal<RequestMetadata> _asyncLocal = new();
Microsoft.Extensions.Logging (1)
LoggerFactoryScopeProvider.cs (1)
18private readonly AsyncLocal<Scope?> _currentScope = new AsyncLocal<Scope?>();
Microsoft.Extensions.Logging.Abstractions (1)
LoggerExternalScopeProvider.cs (1)
14private readonly AsyncLocal<Scope?> _currentScope = new AsyncLocal<Scope?>();
Microsoft.Extensions.Telemetry (1)
Logging\Import\LoggerFactoryScopeProvider.cs (1)
33private readonly AsyncLocal<Scope?> _currentScope = new AsyncLocal<Scope?>();
MSBuild (1)
OutOfProcTaskHostNode.cs (1)
224= new AsyncLocal<TaskExecutionContext>();
NuGet.Common (1)
ActivityCorrelationId.cs (1)
22private static readonly AsyncLocal<string?> _correlationId = new AsyncLocal<string?>();
PresentationCore (1)
MS\Internal\XpsLoadingContext.cs (1)
40private static readonly AsyncLocal<Uri> s_activePackageUri = new();
Roslyn.Diagnostics.Analyzers (1)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Log\RoslynTelemetry.cs (1)
20private static readonly AsyncLocal<RoslynTelemetry?> s_current = new();
System.Diagnostics.DiagnosticSource (1)
System\Diagnostics\Activity.cs (1)
68private static readonly AsyncLocal<Activity?> s_current = new AsyncLocal<Activity?>();
System.Diagnostics.TraceSource (2)
System\Diagnostics\CorrelationManager.cs (2)
13private readonly AsyncLocal<Guid> _activityId = new AsyncLocal<Guid>(); 14private readonly AsyncLocal<StackNode?> _stack = new AsyncLocal<StackNode?>();
System.Private.CoreLib (6)
src\runtime\src\libraries\System.Private.CoreLib\src\System\Diagnostics\Tracing\ActivityTracker.cs (1)
217m_current = new AsyncLocal<ActivityInfo?>(ActivityChanging);
src\runtime\src\libraries\System.Private.CoreLib\src\System\Globalization\CultureInfo.cs (2)
373Interlocked.CompareExchange(ref s_asyncLocalCurrentCulture, new AsyncLocal<CultureInfo>(AsyncLocalSetCurrentCulture), null); 395Interlocked.CompareExchange(ref s_asyncLocalCurrentUICulture, new AsyncLocal<CultureInfo>(AsyncLocalSetCurrentUICulture), null);
src\runtime\src\libraries\System.Private.CoreLib\src\System\Runtime\Loader\AssemblyLoadContext.cs (1)
571Interlocked.CompareExchange<AsyncLocal<AssemblyLoadContext?>?>(ref s_asyncLocalCurrent, new AsyncLocal<AssemblyLoadContext?>(), null);
src\runtime\src\libraries\System.Private.CoreLib\src\System\Runtime\Serialization\SerializationInfo.SerializationGuard.cs (1)
13internal static AsyncLocal<bool> AsyncDeserializationInProgress { get; } = new AsyncLocal<bool>();
src\runtime\src\libraries\System.Private.CoreLib\src\System\Threading\Thread.cs (1)
183Interlocked.CompareExchange(ref s_asyncLocalPrincipal, new AsyncLocal<IPrincipal?>(), null);
System.Security.Principal.Windows (1)
System\Security\Principal\WindowsIdentity.cs (1)
749private static readonly AsyncLocal<SafeAccessTokenHandle?> s_currentImpersonatedToken = new AsyncLocal<SafeAccessTokenHandle?>(CurrentImpersonatedTokenChanged);
System.ServiceModel.Primitives (3)
Internals\System\Runtime\AsyncLock.cs (1)
21_currentSemaphore = new AsyncLocal<SemaphoreSlim>();
System\ServiceModel\OperationContext.cs (1)
22s_asyncContext = new AsyncLocal<OperationContext>();
System\ServiceModel\OperationContextScope.cs (1)
15s_asyncCurrentScope = new AsyncLocal<OperationContextScope>();
System.Threading (1)
System\Threading\HostExecutionContextManager.cs (1)
65_asyncLocal = new AsyncLocal<bool>();
System.Transactions.Local (1)
System\Transactions\Transaction.cs (1)
1061private static readonly AsyncLocal<ContextKey?> s_currentTransaction = new AsyncLocal<ContextKey?>();
74 references to AsyncLocal
aspire (1)
Utils\NpmInstallDetection.cs (1)
28private static readonly AsyncLocal<IEnvironmentReader?> s_environmentOverride = new();
Aspire.Dashboard.Tests (2)
ResourceOutgoingPeerResolverTests.cs (1)
375var ambientValue = new AsyncLocal<string?> { Value = "request" };
TelemetryRepositoryTests\LogTests.cs (1)
824var asyncLocal = new AsyncLocal<string>();
Aspire.Hosting (2)
InteractionService.cs (1)
25private static readonly AsyncLocal<bool> s_nonInteractiveScope = new();
Pipelines\PipelineLoggerProvider.cs (1)
18private static readonly AsyncLocal<StepLoggerHolder?> s_currentStep = new();
Aspire.Hosting.Maui (1)
Lifecycle\MauiBuildQueueEventSubscriber.cs (1)
40private readonly AsyncLocal<bool> _isLaunchTimeoutStop = new();
Aspire.Hosting.Native.Client (1)
NativeProviderDefinition.cs (1)
46private readonly AsyncLocal<NativeClient.ProviderInvocation?> _invocation = new();
Aspire.Hosting.Testing (1)
DistributedApplicationEntryPointInvoker.cs (1)
94private static readonly AsyncLocal<EntryPointInvoker> s_currentListener = new();
GenerateDocumentationAndConfigFiles (1)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Log\RoslynTelemetry.cs (1)
20private static readonly AsyncLocal<RoslynTelemetry?> s_current = new();
GetDocument.Insider (1)
src\dc0dd7c6a4fbfb95\HostFactoryResolver.cs (1)
209private static readonly AsyncLocal<HostingListener> _currentListener = new();
Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore (1)
DatabaseErrorPageMiddleware.cs (1)
24private static readonly AsyncLocal<DiagnosticHolder> _localDiagnostic = new AsyncLocal<DiagnosticHolder>();
Microsoft.AspNetCore.HeaderPropagation (2)
HeaderPropagationMiddleware.cs (1)
26/// The <see cref="HeaderPropagationValues"/> that stores the request headers to be propagated in an <see cref="System.Threading.AsyncLocal{T}"/>
HeaderPropagationValues.cs (1)
13private static readonly AsyncLocal<IDictionary<string, StringValues>?> _headers = new AsyncLocal<IDictionary<string, StringValues>?>();
Microsoft.AspNetCore.Http (1)
HttpContextAccessor.cs (1)
14private static readonly AsyncLocal<HttpContextHolder> _httpContextCurrent = new AsyncLocal<HttpContextHolder>();
Microsoft.AspNetCore.Http.Abstractions (1)
IHttpContextAccessor.cs (1)
10/// This interface should be used with caution. It relies on <see cref="System.Threading.AsyncLocal{T}" /> which can have a negative performance impact on async calls.
Microsoft.AspNetCore.InternalTesting (1)
RepeatContext.cs (1)
10private static readonly AsyncLocal<RepeatContext> _current = new AsyncLocal<RepeatContext>();
Microsoft.AspNetCore.Mvc.Core (1)
Infrastructure\ActionContextAccessor.cs (1)
19private static readonly AsyncLocal<ActionContext> _storage = new AsyncLocal<ActionContext>();
Microsoft.AspNetCore.Mvc.Testing (1)
src\dc0dd7c6a4fbfb95\HostFactoryResolver.cs (1)
209private static readonly AsyncLocal<HostingListener> _currentListener = new();
Microsoft.AspNetCore.TestHost (3)
src\dc0dd7c6a4fbfb95\HostFactoryResolver.cs (1)
209private static readonly AsyncLocal<HostingListener> _currentListener = new();
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.Build (1)
ElementLocation\XmlDocumentWithLocation.cs (1)
59private readonly AsyncLocal<ElementLocation> _elementLocation = new AsyncLocal<ElementLocation>();
Microsoft.Build.Framework (1)
FileUtilities.cs (1)
47private static readonly AsyncLocal<string?> s_currentThreadWorkingDirectory = new();
Microsoft.CodeAnalysis.Analyzers (1)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Log\RoslynTelemetry.cs (1)
20private static readonly AsyncLocal<RoslynTelemetry?> s_current = new();
Microsoft.CodeAnalysis.AnalyzerUtilities (1)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Log\RoslynTelemetry.cs (1)
20private static readonly AsyncLocal<RoslynTelemetry?> s_current = new();
Microsoft.CodeAnalysis.CodeStyle (1)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Log\RoslynTelemetry.cs (1)
20private static readonly AsyncLocal<RoslynTelemetry?> s_current = new();
Microsoft.CodeAnalysis.NetAnalyzers (1)
src\9382845807600969\AnalysisEntityDataFlowOperationVisitor.cs (1)
1189internal static readonly AsyncLocal<Action<object, AnalysisEntityDataFlowScanKind, IOperation>?> Observer = new();
Microsoft.CodeAnalysis.ResxSourceGenerator (1)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Log\RoslynTelemetry.cs (1)
20private static readonly AsyncLocal<RoslynTelemetry?> s_current = new();
Microsoft.CodeAnalysis.Workspaces (1)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Log\RoslynTelemetry.cs (1)
20private static readonly AsyncLocal<RoslynTelemetry?> s_current = new();
Microsoft.Extensions.AI (2)
ChatCompletion\FunctionInvokingChatClient.cs (1)
70private static readonly AsyncLocal<FunctionInvocationContext?> _currentContext = new();
Realtime\FunctionInvokingRealtimeClientSession.cs (1)
58private static readonly AsyncLocal<FunctionInvocationContext?> _currentContext = new();
Microsoft.Extensions.AI.Tests (5)
ChatCompletion\UseDelegateChatClientTests.cs (4)
32AsyncLocal<int> asyncLocal = new(); 81AsyncLocal<int> asyncLocal = new(); 123AsyncLocal<int> asyncLocal = new(); 174AsyncLocal<int> asyncLocal = new();
Embeddings\UseDelegateEmbeddingGeneratorTests.cs (1)
31AsyncLocal<int> asyncLocal = new();
Microsoft.Extensions.AsyncState (2)
AsyncState.cs (1)
15private static readonly AsyncLocal<AsyncStateHolder> _asyncContextCurrent = new();
IAsyncState.cs (1)
11/// Encapsulates all information within the asynchronous flow in an <see cref="AsyncLocal{T}"/> variable.
Microsoft.Extensions.Caching.Memory (2)
CacheEntry.cs (2)
18private static readonly AsyncLocal<CacheEntry?> _current = new AsyncLocal<CacheEntry?>(); 46AsyncLocal<CacheEntry?> holder = _current;
Microsoft.Extensions.Http.Diagnostics (2)
Latency\Internal\HttpClientLatencyContext.cs (1)
11private readonly AsyncLocal<ILatencyContext?> _latencyContext = new();
Logging\Internal\OutgoingRequestContext.cs (1)
11private static readonly AsyncLocal<RequestMetadata> _asyncLocal = new();
Microsoft.Extensions.Logging (1)
LoggerFactoryScopeProvider.cs (1)
18private readonly AsyncLocal<Scope?> _currentScope = new AsyncLocal<Scope?>();
Microsoft.Extensions.Logging.Abstractions (1)
LoggerExternalScopeProvider.cs (1)
14private readonly AsyncLocal<Scope?> _currentScope = new AsyncLocal<Scope?>();
Microsoft.Extensions.Telemetry (1)
Logging\Import\LoggerFactoryScopeProvider.cs (1)
33private readonly AsyncLocal<Scope?> _currentScope = new AsyncLocal<Scope?>();
MSBuild (1)
OutOfProcTaskHostNode.cs (1)
223private readonly AsyncLocal<TaskExecutionContext> _currentTaskContext
mscorlib (1)
parent\ref\mscorlib.cs (1)
1118[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Threading.AsyncLocal<>))]
netstandard (1)
netstandard.cs (1)
2065[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Threading.AsyncLocal<>))]
NuGet.Common (1)
ActivityCorrelationId.cs (1)
22private static readonly AsyncLocal<string?> _correlationId = new AsyncLocal<string?>();
PresentationCore (1)
MS\Internal\XpsLoadingContext.cs (1)
40private static readonly AsyncLocal<Uri> s_activePackageUri = new();
Roslyn.Diagnostics.Analyzers (1)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Log\RoslynTelemetry.cs (1)
20private static readonly AsyncLocal<RoslynTelemetry?> s_current = new();
System.Diagnostics.DiagnosticSource (1)
System\Diagnostics\Activity.cs (1)
68private static readonly AsyncLocal<Activity?> s_current = new AsyncLocal<Activity?>();
System.Diagnostics.TraceSource (4)
System\Diagnostics\CorrelationManager.cs (4)
13private readonly AsyncLocal<Guid> _activityId = new AsyncLocal<Guid>(); 14private readonly AsyncLocal<StackNode?> _stack = new AsyncLocal<StackNode?>(); 53private readonly AsyncLocal<StackNode?> _stack; 55internal AsyncLocalStackWrapper(AsyncLocal<StackNode?> stack)
System.Private.CoreLib (11)
src\runtime\src\libraries\System.Private.CoreLib\src\System\Diagnostics\Tracing\ActivityTracker.cs (1)
602private AsyncLocal<ActivityInfo?>? m_current;
src\runtime\src\libraries\System.Private.CoreLib\src\System\Globalization\CultureInfo.cs (2)
116private static AsyncLocal<CultureInfo>? s_asyncLocalCurrentCulture; 117private static AsyncLocal<CultureInfo>? s_asyncLocalCurrentUICulture;
src\runtime\src\libraries\System.Private.CoreLib\src\System\Runtime\Loader\AssemblyLoadContext.cs (2)
539private static AsyncLocal<AssemblyLoadContext?>? s_asyncLocalCurrent; 571Interlocked.CompareExchange<AsyncLocal<AssemblyLoadContext?>?>(ref s_asyncLocalCurrent, new AsyncLocal<AssemblyLoadContext?>(), null);
src\runtime\src\libraries\System.Private.CoreLib\src\System\Runtime\Serialization\SerializationInfo.SerializationGuard.cs (1)
13internal static AsyncLocal<bool> AsyncDeserializationInProgress { get; } = new AsyncLocal<bool>();
src\runtime\src\libraries\System.Private.CoreLib\src\System\Threading\AsyncLocal.cs (4)
18/// <summary>Instantiates an <see cref="AsyncLocal{T}"/> instance that does not receive change notifications.</summary> 23/// <summary>Instantiates an <see cref="AsyncLocal{T}"/> instance that receives change notifications.</summary> 60/// <summary>Interface to allow non-generic code in ExecutionContext to call into the generic <see cref="AsyncLocal{T}"/> type.</summary> 66/// <summary>The class that provides data change information to <see cref="AsyncLocal{T}"/> instances that register for change notifications.</summary>
src\runtime\src\libraries\System.Private.CoreLib\src\System\Threading\Thread.cs (1)
19private static AsyncLocal<IPrincipal?>? s_asyncLocalPrincipal;
System.Security.Principal.Windows (1)
System\Security\Principal\WindowsIdentity.cs (1)
749private static readonly AsyncLocal<SafeAccessTokenHandle?> s_currentImpersonatedToken = new AsyncLocal<SafeAccessTokenHandle?>(CurrentImpersonatedTokenChanged);
System.ServiceModel.Primitives (3)
Internals\System\Runtime\AsyncLock.cs (1)
14private AsyncLocal<SemaphoreSlim> _currentSemaphore;
System\ServiceModel\OperationContext.cs (1)
28private static AsyncLocal<OperationContext> s_asyncContext;
System\ServiceModel\OperationContextScope.cs (1)
21private static AsyncLocal<OperationContextScope> s_asyncCurrentScope;
System.Threading (2)
src\runtime\artifacts\obj\System.Threading\Release\net12.0\System.Threading.Forwards.cs (1)
5[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Threading.AsyncLocal<>))]
System\Threading\HostExecutionContextManager.cs (1)
57public AsyncLocal<bool>? _asyncLocal;
System.Transactions.Local (1)
System\Transactions\Transaction.cs (1)
1061private static readonly AsyncLocal<ContextKey?> s_currentTransaction = new AsyncLocal<ContextKey?>();