Originally Posted by
Nikel
I actually already changed all the code to perform as a state machine with a Timer calling and checking the state of whatever it is I'm doing. If idle, just exit and do nothing. The next Timer.Tick event will call the state machine again until I have something to do. That way I only do minimal processing every X msec.
Eventually I will change the state machine to work completely on events, as opposed to be called periodically by a Timer. That should not only work better, but also more accurately, since the (imperceptible, but existing) delay between the moment something happened that will give me things to do and the time the Timer fires the processing would go down to zero.
That would also allow me to change the big switch I have to process events and instead deal with function pointers, targeting whatever state I want to move next and use it when the next event fires. That would be particularly useful for the "just waiting" scenario.