public override void Execute() { base.Execute(); //show the ui var progressUi = new ProgressUI(); progressUi.ApplyTheme(Activator.Theme); progressUi.Text = "Refreshing Cohort (" + _extractionConfiguration + ")"; Activator.ShowWindow(progressUi, true); var engine = new CohortRefreshEngine(progressUi, _extractionConfiguration); Task.Run( //run the pipeline in a Thread () => { progressUi.ShowRunning(true); engine.Execute(); } ).ContinueWith(s => { progressUi.ShowRunning(false); //then on the UI thread if (s.IsFaulted) { return; } //issue save and refresh if (engine.Request.CohortCreatedIfAny != null) { Publish(_extractionConfiguration); } }, TaskScheduler.FromCurrentSynchronizationContext()); }