Mach and VB exist in two distinct asynchronous threads. VB (the client) issues requests to Mach (the server). G4 runs in the Mach thread, sleep runs in the VB thread. Requests are not neccessarily run by Mach in the order they are sent by VB. Mach decides on the priority of the request i.e. in which order all the currently queued requests will be run. gcode is higher priority than updating the display.
isMoving() is arguably mis-named - it doesn't neccessarily have anything to do with axis movement, it might have been better if it were called "MachIsBusy()"
Hope this helps
Ian
Yes, this helps very much! I was wondering if the IsMoving was really more than an indication of an axis moving. So I am still not sure when to use sleep versus G4, but I think I have come to one conclusion. Whenever you make a change to Mach, such as changing a DRO, the coordinate system, etc AND you have subsequent code that relies on those changes to be made, you should always add a While Is Moving loop after those changes to make sure Mach has completed them. Is this correct?
Thanks,
Kent