private void RunWorker(PublishWorker publishWorker) { ActivePublishWorkers.Add(publishWorker); try { publishWorker.RunWorkerAsync(outputDirectoryPath); while (publishWorker.IsBusy) { // wait for the scanworker to finish if (CancellationPending) publishWorker.CancelAsync(); System.Threading.Thread.Sleep(500); } } catch (Exception ex) { Logger.Error("Error starting PublishWorker! {0}", ex.ToString()); } Logger.Info("PublishWorker[" + publishWorker.Id + "] ended with result " + publishWorker.PublishWorkerResult.ToString()); ActivePublishWorkers.RemoveAt(0); CompletedPublishWorkers.Add(publishWorker); bankedProgressUnits += publishWorker.TotalProgressUnits; }