System.Runtime.CompilerServices.StateMachineAttribute Class

Allows you to determine whether a method is a state machine method.

See Also: StateMachineAttribute Members


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


You should not apply the StateMachine attribute to methods in your code. For methods that are state machine methods, the compiler will apply the System.Runtime.CompilerServices.AsyncStateMachineAttribute or System.Runtime.CompilerServices.IteratorStateMachineAttribute in the emitted IL.

When checking whether a method is a state machine method, it is preferable to instead check for following attributes, which are derived from StateMachineAttribute:


StateMachineAttribute cannot be used to check whether a method is a state machine method if the method is an iterator method in C#.


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