Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
182 lines (172 sloc) 9.76 KB
<Type Name="AsyncLocal&lt;T&gt;" FullName="System.Threading.AsyncLocal&lt;T&gt;">
<TypeSignature Language="C#" Value="public sealed class AsyncLocal&lt;T&gt;" />
<TypeSignature Language="ILAsm" Value=".class public auto ansi sealed beforefieldinit AsyncLocal`1&lt;T&gt; extends System.Object" />
<TypeSignature Language="DocId" Value="T:System.Threading.AsyncLocal`1" />
<TypeSignature Language="VB.NET" Value="Public NotInheritable Class AsyncLocal(Of T)" />
<TypeSignature Language="C++ CLI" Value="generic &lt;typename T&gt;&#xA;public ref class AsyncLocal sealed" />
<TypeSignature Language="F#" Value="type AsyncLocal&lt;'T&gt; = class" />
<AssemblyInfo>
<AssemblyName>System.Threading</AssemblyName>
<AssemblyVersion>4.0.10.0</AssemblyVersion>
<AssemblyVersion>4.1.0.0</AssemblyVersion>
<AssemblyVersion>4.1.1.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>mscorlib</AssemblyName>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<TypeParameters>
<TypeParameter Name="T" />
</TypeParameters>
<Base>
<BaseTypeName>System.Object</BaseTypeName>
</Base>
<Interfaces />
<Docs>
<typeparam name="T">The type of the ambient data.</typeparam>
<summary>Represents ambient data that is local to a given asynchronous control flow, such as an asynchronous method.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
Because the task-based asynchronous programming model tends to abstract the use of threads, <xref:System.Threading.AsyncLocal%601> instances can be used to persist data across threads.
The <xref:System.Threading.AsyncLocal%601> class also provides optional notifications when the value associated with the current thread changes, either because it was explicitly changed by setting the <xref:System.Threading.AsyncLocal%601.Value%2A> property, or implicitly changed when the thread encountered an `await` or other context transition.
## Examples
The following example uses the <xref:System.Threading.AsyncLocal%601> class to persist a string value across an asynchronous flow. It also contrasts the use of <xref:System.Threading.AsyncLocal%601> with <xref:System.Threading.ThreadLocal%601>.
[!code-csharp[System.Threading.AsyncLocal#1](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.threading.asynclocal/cs/Example1.cs#1)]
[!code-vb[System.Threading.AsyncLocal#1](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.threading.asynclocal/vb/Example1.vb#1)]
]]></format>
</remarks>
</Docs>
<Members>
<MemberGroup MemberName=".ctor">
<AssemblyInfo>
<AssemblyName>System.Threading</AssemblyName>
<AssemblyVersion>4.0.10.0</AssemblyVersion>
<AssemblyVersion>4.1.0.0</AssemblyVersion>
</AssemblyInfo>
<Docs>
<summary>Instantiates an <see cref="T:System.Threading.AsyncLocal`1" /> instance.</summary>
</Docs>
</MemberGroup>
<Member MemberName=".ctor">
<MemberSignature Language="C#" Value="public AsyncLocal ();" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig specialname rtspecialname instance void .ctor() cil managed" />
<MemberSignature Language="DocId" Value="M:System.Threading.AsyncLocal`1.#ctor" />
<MemberSignature Language="VB.NET" Value="Public Sub New ()" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; AsyncLocal();" />
<MemberType>Constructor</MemberType>
<AssemblyInfo>
<AssemblyName>System.Threading</AssemblyName>
<AssemblyVersion>4.0.10.0</AssemblyVersion>
<AssemblyVersion>4.1.0.0</AssemblyVersion>
<AssemblyVersion>4.1.1.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>mscorlib</AssemblyName>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<Parameters />
<Docs>
<summary>Instantiates an <see cref="T:System.Threading.AsyncLocal`1" /> instance that does not receive change notifications.</summary>
<remarks>To be added.</remarks>
</Docs>
</Member>
<Member MemberName=".ctor">
<MemberSignature Language="C#" Value="public AsyncLocal (Action&lt;System.Threading.AsyncLocalValueChangedArgs&lt;T&gt;&gt; valueChangedHandler);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig specialname rtspecialname instance void .ctor(class System.Action`1&lt;valuetype System.Threading.AsyncLocalValueChangedArgs`1&lt;!T&gt;&gt; valueChangedHandler) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Threading.AsyncLocal`1.#ctor(System.Action{System.Threading.AsyncLocalValueChangedArgs{`0}})" />
<MemberSignature Language="VB.NET" Value="Public Sub New (valueChangedHandler As Action(Of AsyncLocalValueChangedArgs(Of T)))" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; AsyncLocal(Action&lt;System::Threading::AsyncLocalValueChangedArgs&lt;T&gt;&gt; ^ valueChangedHandler);" />
<MemberSignature Language="F#" Value="new System.Threading.AsyncLocal&lt;'T&gt; : Action&lt;System.Threading.AsyncLocalValueChangedArgs&lt;'T&gt;&gt; -&gt; System.Threading.AsyncLocal&lt;'T&gt;" Usage="new System.Threading.AsyncLocal&lt;'T&gt; valueChangedHandler" />
<MemberType>Constructor</MemberType>
<AssemblyInfo>
<AssemblyName>System.Threading</AssemblyName>
<AssemblyVersion>4.0.10.0</AssemblyVersion>
<AssemblyVersion>4.1.0.0</AssemblyVersion>
<AssemblyVersion>4.1.1.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>mscorlib</AssemblyName>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute FrameworkAlternate="netcore-1.0;netcore-1.1;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netstandard-1.3;netstandard-1.4;netstandard-1.6;xamarinandroid-7.1;xamarinios-10.8;xamarinmac-3.0;netframework-4.8;netcore-2.0;dotnet-uwp-10.0">
<AttributeName>System.Security.SecurityCritical</AttributeName>
</Attribute>
</Attributes>
<Parameters>
<Parameter Name="valueChangedHandler" Type="System.Action&lt;System.Threading.AsyncLocalValueChangedArgs&lt;T&gt;&gt;" />
</Parameters>
<Docs>
<param name="valueChangedHandler">The delegate that is called whenever the current value changes on any thread.</param>
<summary>Instantiates an <see cref="T:System.Threading.AsyncLocal`1" /> local instance that receives change notifications.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The delegate's signature is `Action<ASyncLocalValueChangedArgs<T>`.
]]></format>
</remarks>
<altmember cref="T:System.Threading.AsyncLocalValueChangedArgs`1" />
</Docs>
</Member>
<Member MemberName="Value">
<MemberSignature Language="C#" Value="public T Value { get; set; }" />
<MemberSignature Language="ILAsm" Value=".property instance !T Value" />
<MemberSignature Language="DocId" Value="P:System.Threading.AsyncLocal`1.Value" />
<MemberSignature Language="VB.NET" Value="Public Property Value As T" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; property T Value { T get(); void set(T value); };" />
<MemberSignature Language="F#" Value="member this.Value : 'T with get, set" Usage="System.Threading.AsyncLocal&lt;'T&gt;.Value" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.Threading</AssemblyName>
<AssemblyVersion>4.0.10.0</AssemblyVersion>
<AssemblyVersion>4.1.0.0</AssemblyVersion>
<AssemblyVersion>4.1.1.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>mscorlib</AssemblyName>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute FrameworkAlternate="netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;xamarinandroid-7.1;xamarinios-10.8;xamarinmac-3.0;netframework-4.8">
<AttributeName>get: System.Security.SecuritySafeCritical</AttributeName>
</Attribute>
<Attribute FrameworkAlternate="netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;xamarinandroid-7.1;xamarinios-10.8;xamarinmac-3.0;netframework-4.8">
<AttributeName>set: System.Security.SecuritySafeCritical</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>T</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets or sets the value of the ambient data.</summary>
<value>The value of the ambient data. If no value has been set, the returned value is <c>default(T)</c>.</value>
<remarks>To be added.</remarks>
</Docs>
</Member>
</Members>
</Type>
You can’t perform that action at this time.