I am developing an OBD2 scanner app for windows using C#. I was hoping someone could tell me the optimal time to wait for a response (using thread.Sleep()) from the car's ecu before reading the response from the serial port.
I am developing using a bluetooth adapter and the Baud rate is 9600. I've currently got my wait period set to 100ms, but I am hoping to go much shorter than that if possible. I just don't want to run into a situation where I try to read data when the port is not ready. I want to get a good trade-off between a smooth GUI and comfortable margins for error.
UPDATE: thanks of the ideas. Handling DataReceived is a good general idea but the reason I'm sleeping a thread is that I need to poll the ECU repeatedly at intervals so that I can do things like update an RPM gauge. I am trying to find a sweetspot where I am getting as many reps as possible from the ECU, without overwhelming it. If I were polling it once only, then simply handling an event would be fine, but I need to know what an acceptable interval would be between polls. I will definitely change my code to be event-driven, but I still need to know how long is a respectable time between polls.