I am currently trying to write some code which is going to send a request to a device, and then wait for the response. The problem is the response does not have an end character to indicate the message is complete so we just have to wait a period of time.
What I want to do is send the message and then wait a period of time. Each time a piece of data arrives I want to increment the period of time I am waiting by say another 100ms incase there is any more data to follow. If nothing comes in after that period it is assumed that the message is complete. This is the pseudo code I came up with:
var waitTime
Function SendData(data)
{
send the request here and then block with the next code
while (waitTime)
{
//wait
}
}
Function RecieveData(data)
{
Assign new data to a buffer
waitTime++
}
The SendData and RecieveData functions are both on different threads within a class. I am coding this in C#. I have tried implementing this with a DataTime object, but it does not seem to be very accurate when working with 10's/100's of milliseconds?
Any advice on what would be the best way to implement this would be appreciated!
Regards Adrian