I have the following data received event handler for serial communications. My com port object has a ReceivedBytesThreshold set to 18. The problem I have is the data coming into the com port ranges from 8 bytes to 160 bytes and I don't always get the entire message. Whenever I step through in debug mode all bytes are captureed in the buffer. Is there a way to delay the event from firing until all bytes are received., without having to constantly create an instance of the serial port and change the ReceivedBytesThreshold?
private void comm_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
int bytes = comm.BytesToRead;
commBuffer = new byte[bytes];
comm.Read(commBuffer, 0, bytes);
newMessage(commBuffer, NewMessageEventArgs.messageType.Status);