calling a serialport handle from a loop
Hi guys his my problem:
I am trying to run the function:
Code:
Private Sub port_dataReceived(ByVal sender As Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles port.DataReceived
from inside a while loop of a different function ie.
Code:
While A_switch = 0
System.Threading.Thread.Sleep(100) ' Sleep for .1 second
calabrate_send = calabrate_send - 5
port.WriteLine("9 1 ")
port.WriteLine(calabrate_send)
port.WriteLine("a")
end While
the real problem is that the serial call updates the value of A_switch which is need to exit the loop at the correct time
if anyone knows how to do this or has a better method i would love to hear -cheers robbo
Re: calling a serialport handle from a loop
Re: calling a serialport handle from a loop
solved the problem using
Code:
System.Windows.Forms.Application.DoEvents()
however this results in a heep of data at the serialport buffer built up hence i might need to use clear to send i guess
thanks