using System.Activities.Statements; StateMachine stateMachine = new StateMachine(); var idleState = new State("Idle"); var walkingState = new State("Walking"); idleState .TransitionTo(walkingState) .When(() => Console.KeyAvailable) .Execute(() => Console.WriteLine("Walking...")); walkingState .TransitionTo(idleState) .When(() => !Console.KeyAvailable) .Execute(() => Console.WriteLine("Idle.")); stateMachine.Start(idleState); while (true) { stateMachine.Update(); Thread.Sleep(100); // sleep for 100ms to reduce CPU usage }In this example, we are creating a simple state machine that switches between idle and walking states based on whether a key is pressed. The state machine is executed in a loop, and the `Update()` method is called on every iteration. The `Thread.Sleep()` call is added to avoid excessive CPU usage. The package library for the StateMachine class is part of the System.Activities.Statements namespace, which is part of the .NET Framework Class Library.