async void StartLoop() { _robotMessage = "Robot loop started."; _looping = true; while (_looping) { if (!_robotAwaiting) { await Task.Run(() => _robotAwaiting = (_server.Read() == 1)); } if (!_looping) { return; } if (_robotAwaiting) { if (_stackable == null) { Initialize(); } _currentData = _stackable.GetNextTargets(); if (_currentData == null || _currentData.StopLoop) { StopLoop(); return; } _server.SendTargets(_currentData.Retract ? 2 : 1, BestGrip(_currentData.Pick), BestGrip(_currentData.Place)); _robotAwaiting = false; } } }
async void StartLoop() { _robotMessage = "Robot loop started."; _looping = true; while (_looping) { if (!_robotAwaiting) { _robotAwaiting = await _server.ReadAsync() == 1; } if (!_looping) { return; } if (_robotAwaiting) { _currentData = _stackable.GetNextTargets(); if (_currentData == null || _currentData.StopLoop) { StopLoop(); return; } await _server.SendTargetsAsync( _currentData.Retract? 2 : 1, BestGrip(_currentData.Pick), BestGrip(_currentData.Place) ); _robotAwaiting = false; } } }