private void Run() { if (CanRun && !RunningSequence) { SetCycleParams(RepeatRun, RepeatContinuously, RepeatCount); ELLDeviceSequence sequence = new ELLDeviceSequence(); sequence.Sequence = _sequence.Items.Select(item => sequence.CreateCommand(_ellDevices, _ellDevices.ValidAddresses(item.Addresses), item.Command, item.WaitTime, item.Parameter1, item.Parameter2)).ToList(); _owner.BackgroundThreadManager.RunBackgroundFunction((s, e) => RunSequenceEx(sequence)); } }
private void RunSequenceEx(ELLDeviceSequence sequence) { _dispatcher.Execute(() => { RunningSequence = true; }); _runningCycleCount = 1; while (RunningSequence && KeepRunning()) { int index = 0; while (RunningSequence && (index < sequence.Sequence.Count)) { UpdateRunningState(index + 1, sequence.Sequence[index].Address, _runningCycleCount, sequence.Sequence[index].Description, "Active"); sequence.Sequence[index].ELLFunction.Invoke(); WaitForTimeElapsed(sequence.Sequence[index].WaitTime); index++; } _runningCycleCount++; } _dispatcher.Execute(() => { RunningSequence = false; }); UpdateRunningState(null, '\0', _runningCycleCount, null, null); }