public void GetTokens() { Progress = new GettingTokensProgressReportModel(); Progress.MaxProgress = Plants.Sum(x => x.LeafImages.Count);; Progress.ImagesProcessed = 0; Progress.Status = "Obrađivanje..."; dynamic settings = SetSettingsForProgressReportPopup(); Task.Run(() => { foreach (var plant in Plants) { foreach (var leafImage in plant.LeafImages) { ImageProcessor imageProcessor = new ImageProcessor(leafImage); imageProcessor.EdgeDetect(Threshold); imageProcessor.Thinning(); imageProcessor.CheckLines(MinLine); imageProcessor.MarkPoints(Distance); imageProcessor.CalcAngels(); List <LeafToken> leafTokens = imageProcessor.GetTokens(); double[] input = new double[NumberOfInputNodes]; for (int i = 0; i < NumberOfInputNodes; i++) { input[i] = i < leafTokens.Count - 1 ? leafTokens[i].Sin : 0; } double[] output = new double[Plants.Count]; for (int i = 0; i < Plants.Count; i++) { output[i] = i == plant.Id ? 1.0 : 0.0; } DataPoint dataPoint = new DataPoint(input, output); _dataSet.Data.Add(dataPoint); Progress.ImagesProcessed++; NotifyOfPropertyChange(() => Progress); ProgressChanged?.Invoke(this, Progress); } } SaveData(); NotifyOfPropertyChange(() => CanTrainNetwork); }); WindowManager window = new WindowManager(); window.ShowDialog(new GettingTokensProgressBarViewModel(ref _progress, settings, this)); }