private void RunCloud() { _isRunning = true; CancelCommand.RaiseCanExecuteChanged(); FileOpenCommand.RaiseCanExecuteChanged(); _cancellationToken = new CancellationTokenSource(); ThreadPool.QueueUserWorkItem(DoWork, _cancellationToken); }
private void DoWork(object state) { var cancellationToken = ((CancellationTokenSource)state).Token; // Execute the process steps var step1 = new ExecuteExcelToCsvProcessStep(_eventAggregator, _logger, 1); step1.Run(cancellationToken); var step2 = new ExecuteCreateZipFileProcessStep(_eventAggregator, _logger, 2); step2.Run(cancellationToken); // Update the UI command state Dispatcher.CurrentDispatcher.Invoke(() => { _isRunning = false; RunCloudCommand.RaiseCanExecuteChanged(); CancelCommand.RaiseCanExecuteChanged(); FileOpenCommand.RaiseCanExecuteChanged(); }); }