I've gone through .NET's help manuals trying to solve this, and so far I haven't found an answer satisfactory enough for me.
I want to pause the execution of a thread until the value of a variable (MotionInProgress) becomes false.
What the program does, is it assigns an event handler for when characters are received at the serial port.
When this happens, the screen is updated with the new reported values that arrived at the serial port.
The instructions go like this:
What I'd like to do is use something else than the While-EndWhile loop that continuously polls the value of MotionInProgress... it just looks so unelegant...
I want to pause the execution of a thread until the value of a variable (MotionInProgress) becomes false.
What the program does, is it assigns an event handler for when characters are received at the serial port.
When this happens, the screen is updated with the new reported values that arrived at the serial port.
The instructions go like this:
Code:
TransSerial(cmd_jog_out) 'send jog command through the serial port
MotionInProgress = True 'seed the motion in progress flag as true
'at this point, the controller will start sending out data, and when
'that happens, the SPortDataReceivedHandler will take care of the process
AddHandler SPort.DataReceived, AddressOf SPortDataReceivedHandler
'wait here until MotionInProgress is received as false
While MotionInProgress : Threading.Thread.Sleep(10) : End While
'remove the serial port event handler, and resume normal program execution
RemoveHandler SPort.DataReceived, AddressOf SPortDataReceivedHandler
Last edited: