AsyncLocal<T>
E697536
AsyncLocal<T> is a .NET type that provides ambient data storage local to a given asynchronous control flow, allowing values to flow with async calls without using thread-local storage.
Statements (46)
| Predicate | Object |
|---|---|
| instanceOf |
generic class
ⓘ
reference type ⓘ |
| apiSurface | minimal API with Value property and optional change callback ⓘ |
| assembly |
System.Private.CoreLib (in .NET Core / .NET 5+)
NERFINISHED
ⓘ
System.Threading (in some .NET Core versions) NERFINISHED ⓘ mscorlib (in .NET Framework) NERFINISHED ⓘ |
| behavior |
value does not automatically flow to new threads without ExecutionContext flow
ⓘ
value is captured and restored across async awaits ⓘ |
| category |
concurrency utility
ⓘ
context propagation primitive ⓘ |
| contrastWith | ThreadLocal<T> which is bound to a specific thread ⓘ |
| definedIn | System.Threading namespace NERFINISHED ⓘ |
| design |
uses ExecutionContext to flow values
ⓘ
values are copied when ExecutionContext is captured ⓘ |
| documentation | documented on Microsoft Learn ⓘ |
| genericTypeParameter | T ⓘ |
| hasConstructor |
AsyncLocal()
ⓘ
AsyncLocal(Action<AsyncLocalValueChangedArgs<T>> valueChangedHandler) ⓘ |
| hasEventLikeCallback | ValueChanged ⓘ |
| hasProperty |
Value
ⓘ
ValueChanged ⓘ |
| introducedIn |
.NET Core 1.0
NERFINISHED
ⓘ
.NET Framework 4.6 NERFINISHED ⓘ |
| lifetime | lives as long as the AsyncLocal<T> instance is referenced ⓘ |
| partOf | .NET Base Class Library NERFINISHED ⓘ |
| platform |
.NET 5+
NERFINISHED
ⓘ
.NET Core NERFINISHED ⓘ .NET Framework NERFINISHED ⓘ |
| purpose |
allow values to flow with async calls
ⓘ
avoid reliance on thread-local storage in async code ⓘ provide ambient data storage local to an asynchronous control flow ⓘ |
| relatedTo |
AsyncFlowControl
NERFINISHED
ⓘ
CallContext NERFINISHED ⓘ ExecutionContext NERFINISHED ⓘ ThreadLocal<T> NERFINISHED ⓘ |
| scope |
value flows with async continuations
ⓘ
value is scoped to the current async control flow ⓘ |
| supports |
asynchronous call context data
ⓘ
logical call context propagation ⓘ |
| threadAffinity | not bound to a specific thread ⓘ |
| threadSafety | Value property is thread-safe for simple get and set operations ⓘ |
| usagePattern |
commonly used for ambient configuration or security context
ⓘ
commonly used for logging correlation identifiers ⓘ commonly used for per-request context in ASP.NET Core ⓘ |
| valueAccessibility | Value property is gettable and settable ⓘ |
| valueChangeNotification | ValueChanged callback invoked when value changes in current or parent context ⓘ |
Referenced by (1)
Full triples — surface form annotated when it differs from this entity's canonical label.