I have a class-service which control connection and data exchange beetwen CNC shell program and CNC controller. This class implement some methods among which GetResponse method.
...
public bool GetResponse(string query, out string result)
...
This method sends command to cnc controller. It may be success or fall. Method returns operation successfulity. "string result" returns code of error, or empty string if operation success. Sometimes I need to send command J+ (jogging) and A(stop jogging). Command J+ does continuous jogging of machine. Command A stops this joggind. Controller is connected through an ethernet. Sometimes GetResponse method may not send command and return false. But if it don't sends command A (stop jogging) then I have big problem, machine don't stay.
I could execute GetResponse method in "while loop" while it don't return success, but if it don't return succes never I will have new problem - deadlocking my program (infinite while loop).
Also I can implement queue of commands and this method will free the queue when it's commands executed successfully. But if the queue is too full, commands will not work in time and A command(stop jogging) execute too late. Is there a best practice in such cases?