private void pararCaptura() { ChangeLabelEvent?.Invoke(this, new ChangeLabelStatusEventArgs("Pronto.")); btnIniciar.IsEnabled = true; btnParar.IsEnabled = false; if (isRunning == true) { cts.Cancel(); cts.Dispose(); isRunning = false; } }
private void BtnIniciar_Click(object sender, RoutedEventArgs e) { ChangeLabelEvent?.Invoke(this, new ChangeLabelStatusEventArgs("Processando...")); btnParar.IsEnabled = true; btnIniciar.IsEnabled = false; isRunning = true; cts = new CancellationTokenSource(); //Thread Action = new Thread(new ThreadStart(action)); Thread Action = new Thread(() => workerClass.Action(configAcquisitionDevice, cts.Token, window)); Action.IsBackground = true; Action.Start(); }