public void Init(ILawnMowingMachine machine) { Logger.Info($"Starting LownManager initialization of size ({machine.SizeX}, {machine.SizeY})"); lock (SyncRoot) { //Cancel old execution if (_initialized) { _cancelSource.Cancel(); } _cancelSource = new CancellationTokenSource(); var machineThread = new Thread(() => { while (true) { Action action; while (_commands.TryDequeue(out action)) { if (_cancelSource.Token.IsCancellationRequested) { return; } _currentAction = action; _currentAction(); } if (_cancelSource.Token.IsCancellationRequested) { return; } Thread.Sleep(1000); } }); machineThread.IsBackground = true; machineThread.Start(); _machine = machine; _initialized = true; } }
public SLMMController(ILawnMowingMachine machine) { _machine = machine; }