Mercurial > hg > orthanc-wsi
diff Applications/ApplicationToolbox.cpp @ 7:bc3ca410b765
Fix freeze if the target Orthanc is not accepting images
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 26 Oct 2016 15:42:52 +0200 |
parents | 4a7a53257c7d |
children | 62adabb8c122 |
line wrap: on
line diff
--- a/Applications/ApplicationToolbox.cpp Wed Oct 26 14:00:54 2016 +0200 +++ b/Applications/ApplicationToolbox.cpp Wed Oct 26 15:42:52 2016 +0200 @@ -74,30 +74,36 @@ { if (threadsCount > 1) { + // Submit the tasks to a newly-created processor LOG(WARNING) << "Running " << tasks.GetSize() << " tasks"; LOG(WARNING) << "Using " << threadsCount << " threads for the computation"; Orthanc::BagOfTasksProcessor processor(threadsCount); std::auto_ptr<Orthanc::BagOfTasksProcessor::Handle> handle(processor.Submit(tasks)); + // Start a thread to display the progress bool done = false; boost::thread progress(PrintProgress, handle.get(), &done); - if (handle->Join()) + // Wait for the completion of the tasks + bool success = handle->Join(); + + // Stop the progress-printing thread + done = true; + + if (progress.joinable()) { - done = true; + progress.join(); + } + + if (success) + { LOG(WARNING) << "All tasks have finished"; } else { - done = true; LOG(ERROR) << "Error has occurred, aborting"; throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); } - - if (progress.joinable()) - { - progress.join(); - } } else {