private void RunUntil(object state)
{
if (state == null)
return;
//stop all motors!
BrickPortMotor[] ports = (BrickPortMotor[])state;
for (int i = 0; i < ports.Length; i++)
{
StopMotor((int)ports[i]);
}
if(timer!=null)
{
timer.Dispose();
timer = null;
}
}