You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I have a state machine with 2 states: Idle and Pinging.
Pinging state permits reentry, to loop the ping forever.
The problem is that when I call _Machine.Fire(Triggers.Ping), the call does not exit.
Is there a better way to handle looping states?
Here a sample code:
// See https://aka.ms/new-console-template for more informationusing Stateless;var_MachineSynch=newStateMachine<State,Triggers>(State.Idle);
_MachineSynch.Configure(State.Idle).Permit(Triggers.Ping, State.Pinging).OnEntry(OnDisconnect);
_MachineSynch.Configure(State.Pinging).PermitReentry(Triggers.Ping).Permit(Triggers.Disconnect, State.Idle).OnEntry(OnPing);voidOnDisconnect(){
Task.Delay(100).Wait();
Console.WriteLine("Disconnected");}voidOnPing(){
Console.WriteLine("Pinging...");
Task.Delay(1000).Wait();
Console.WriteLine("PingED. repinging");
_MachineSynch.Fire(Triggers.Ping);
Console.WriteLine("PingED. repinged");}//start synch
_MachineSynch.Fire(Triggers.Ping);
Console.WriteLine("FIRED");//NEVER ARRIVES HEREpublicenumState{Idle,Pinging,}publicenumTriggers{//Connect,Ping,Disconnect,}
The text was updated successfully, but these errors were encountered:
Hi, I have a state machine with 2 states: Idle and Pinging.
Pinging state permits reentry, to loop the ping forever.
The problem is that when I call
_Machine.Fire(Triggers.Ping)
, the call does not exit.Is there a better way to handle looping states?
Here a sample code:
The text was updated successfully, but these errors were encountered: