Hi all, in my application, there are multiple threads. The 1st threads will move the motor from point to point and read back the position of the motor after every point movement and this will keep running until the user trigger PAUSE. The 2nd thread will be fired when the user triggered the PAUSE button in my application. In the click event of the pause button, it actually fires the 2nd thread and prompt a form, and in the form activated event, it will communicate with the motor and read back the position of the motor before it stop the motor movement.
However, there is problem at that instance where the 2nd thread and 1st thread is trying to access the motor information at the same time and my application prompts error.
The 1st thread has moved to a point and send a query command to the motor to request the position and at this instance (before the motor actually reply), the 2nd thread is trying to send the query command again to request the motor position and this instance the motor couldn't respond properly.
So may i know how do i make sure the 2nd thread will only send the query command after the 1st thread has done its request?
Event or Global variable?
Please advise.
However, there is problem at that instance where the 2nd thread and 1st thread is trying to access the motor information at the same time and my application prompts error.
The 1st thread has moved to a point and send a query command to the motor to request the position and at this instance (before the motor actually reply), the 2nd thread is trying to send the query command again to request the motor position and this instance the motor couldn't respond properly.
So may i know how do i make sure the 2nd thread will only send the query command after the 1st thread has done its request?
Event or Global variable?
Please advise.