private void SignalMotionComplete(object state) { MotionCompleteEvent.Set(); timer.Dispose(); IsSystemInMotion = false; motionsToExecute.Clear(); }
public void StartMotionClock() { if (motionsToExecute.Any()) { MotionCompleteEvent.Reset(); IsSystemInMotion = true; var maxTime = motionsToExecute.Max(); Console.WriteLine($"Waiting {maxTime * 1000} ms for motion to complete..."); timer = new Timer(SignalMotionComplete, null, (int)(maxTime * 1000), Timeout.Infinite); } else { MotionCompleteEvent.Set(); IsSystemInMotion = false; } }