private void SendCommmands()
{
try
{
while (true)
{
var waitResult = _itemsReadyEvent.WaitOne(100);
if (!waitResult)
{
if (_disconnected)
{
break;
}
continue;
}
CommandWithActions toSendThisTime = null;
lock (_commandsToSend)
{
toSendThisTime = _commandsToSend.Dequeue();
if (_commandsToSend.Count == 0)
{
_itemsReadyEvent.Reset();
}
}
SendCommand(toSendThisTime);
}
}
catch (SpheroPluginException exception)
{
// assume disconnected
RaiseDisconnected();
}
}