Beispiel #1
0
        void AsyncWorkerProcess_DoWork(object sender, DoWorkEventArgs e)
        {
            while (!AsyncWorkerProcess.CancellationPending)
            {
                fg.Update();
            }

            if (AsyncWorkerProcess.CancellationPending)
            {
                e.Cancel = true;
            }
        }
Beispiel #2
0
        void AsyncWorkerRecord_DoWork(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker bwAsync = sender as BackgroundWorker;

            LastRecodredFeatureVectorsCount = 0;
            bwAsync.ReportProgress(0);

            startRecord = DateTime.Now;
            recordTimer.Start();

            while (!bwAsync.CancellationPending)
            {
                fg.Update();
            }

            if (bwAsync.CancellationPending)
            {
                e.Cancel = true;
            }

            bwAsync.ReportProgress(100);
        }
        private void buttonProcess_Click(object sender, RoutedEventArgs e)
        {
            if (listModels.SelectedIndex == -1)
            {
                MessageBox.Show("No model selected!"); return;
            }

            buttonProcess.IsEnabled = false;
            taskClassification      = Task.Factory.StartNew(() =>
            {
                while (true)
                {
                    fg.Update();
                }
            });

            progressReporterClassification.RegisterContinuation(taskClassification, () =>
            {
                buttonProcess.IsEnabled = false;

                if (taskClassification.Exception != null)
                {
                    statusBar.Text = "Error ocurred during classification!";
                    MessageBox.Show("Error:" + taskClassification.Exception.Message);
                    //log
                }
                else if (taskClassification.IsCanceled)
                {
                    statusBar.Text = "Classification cancelled.";
                }
                else //all OK
                {
                    //no more signal
                }
            });
        }