using System; using System.Collections.Generic; using System.Threading; using System.Windows.Threading; using SignalsMVVM.Interfaces; namespace SignalsMVVM.Models { public class LogController : IProcedureLogger { private Action IsThreadAlive { get; set; } private Dispatcher MainDispatcher { get; set; } private IList InputList { get; set; } private IList OutputList { get; set; } public LogController(Dispatcher dispatcher, IList inputList, IList outputList, Action isThreadAlive) { MainDispatcher = dispatcher; InputList = inputList; OutputList = outputList; IsThreadAlive = isThreadAlive; } public void ExecuteThread() { IsThreadAlive(true); foreach (BaseSignal signal in InputList) { MainDispatcher.Invoke(() => OutputList.Add(signal)); Thread.Sleep(signal.Delay); } IsThreadAlive(false); } } }