private void Sleep(int mstimeout, ICommsSerial comPort = null)
{
var endtime = DateTime.Now.AddMilliseconds(mstimeout);
while (DateTime.Now < endtime)
{
Thread.Sleep(1);
Application.DoEvents();
// prime the mavlinkserial loop with data.
if (comPort != null)
{
var test = comPort.BytesToRead;
test++;
}
}
}