My application reads every x ms some data from a serial port(MyDataReader) and displays it on a control, MyDataReader also can be a file, from which I can read data.
I used a simple timer, every tick I've read the data from the serial port/file, processed it and displayed it, It worked great.
Now I've added another device from which I need to read data and I've switched to System.Threading.Timer, but now my "tick" function is not working properly, when it reads from the serial port, I get zeros. when I enter debug mode and breakpoint readfromserialport function, sometimes I get valid data, sometimes I don't.
If I switch the reading from serialport to read from file it works fine, I've invoked all the controls that display data.
I locked the read/write from the serialport:
anyone have any idea why I get zeros all the time, and when I breakpoint I have sometimes data?
It's like it opens the read from serial port on different thread and I need to wait to the data to be read.
Code block added - OriginalGriff[/edit]
Added additional information[/edit]
Moved from OP's "solution":
I'm looking for the cause for the difference between regular timer and Threading.Timer, when I read data from the port with regular timer everything is ok, when I change it to Threading.Timer then I get no data.
BTW, in order to get data from my device I need to write a request, I write a request and immediately get response with data.