C# state machine sample