System.Runtime.CompilerServices.AsyncStateMachineAttribute Class

Indicates whether a method is marked with either the Async (Visual Basic) or async (C# Reference) modifier.

See Also: AsyncStateMachineAttribute Members


[System.AttributeUsage(System.AttributeTargets.Method, Inherited=false)]
public sealed class AsyncStateMachineAttribute : StateMachineAttribute


You shouldn't apply the AsyncStateMachine attribute to methods in your code. For methods that have the async modifier, the compiler will apply the AsyncStateMachine attribute in the IL that the compiler emits.

When a method (MethodName) has the Async or async modifier, the compiler emits IL that includes a state machine structure. This structure contains the code in the method. That IL also contains a stub method (MethodName) that calls into the state machine. The compiler adds the AsyncStateMachine attribute to the stub method so that tools can identify the corresponding state machine. Details of the emitted IL might change in future releases of the compilers.

For information about the Async feature, see Asynchronous Programming with Async and Await (C# and Visual Basic).


Namespace: System.Runtime.CompilerServices
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: