Exemplo n.º 1
0
        private void TestingWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            var worker = e.Argument as TestingWorkerSender;

            if (!Started)
            {
                WorkingSets.local.TestResults.Rows.Add(worker.job.Information.ToDataRow(worker.job));
                WorkingSets.local.saveTestResults();
                Started = true;
            }
            while (worker.CurrentItemIndex < worker.MeasurementItems.Length)
            {
                if (worker.CurrentItemIndex + 1 == worker.MeasurementItems.Length &&
                    worker.MeasurementItems[worker.CurrentItemIndex].completed == true)
                {
                    worker.ProgressPercent = (worker.MeasurementItems.Where(p => p.completed == true).Count()) * 100 / worker.MeasurementItems.Length;
                    TestingWorker.ReportProgress(worker.ProgressPercent, worker);
                    if (worker.MeasurementItems.Where(p => p.redo == true).Count() > 0)
                    {
                        if (reDoMark(worker))
                        {
                            continue;
                        }
                        else
                        {
                            return;
                        }
                    }
                    else
                    {
                        Application.Current.Dispatcher.Invoke(() => SetgroupboxVisible(Whichgroupbox.FINISH));
                        return;
                    }
                }
                if (TestingWorker.CancellationPending == true)
                {
                    while (!Measurement.CancelWork(ref worker))
                    {
                        TestingWorker.ReportProgress(0, worker);
                        Thread.Sleep(50);
                    }
                    return;
                }
                else
                {
                    if (!worker.MeasurementItems[worker.CurrentItemIndex].completed)
                    {
                        Measurement.DoWork(ref worker);
                        showMassege(worker);
                    }
                    else
                    {
                        worker.CurrentItemIndex++;
                    }
                }
                var process = worker.MeasurementItems.Where(p => p.completed == true);
                worker.ProgressPercent = process.Count() * 100 / worker.MeasurementItems.Length;
                TestingWorker.ReportProgress(worker.ProgressPercent, worker);
                Thread.Sleep(100);
            }
        }