@@ -955,8 +955,9 @@ private void busyCursorWhile(Runnable dialogWaitRunnable, ProgressMonitorJobsDia
955955 * Schedules the job that will open the progress monitor dialog.
956956 *
957957 * @param dialog the dialog to open
958+ * @return the job that was scheduled to open the dialog
958959 */
959- private void scheduleProgressMonitorJob (final ProgressMonitorJobsDialog dialog ) {
960+ private Job scheduleProgressMonitorJob (final ProgressMonitorJobsDialog dialog ) {
960961 final WorkbenchJob updateJob = new WorkbenchJob (ProgressMessages .ProgressManager_openJobName ) {
961962 @ Override
962963 public IStatus runInUIThread (IProgressMonitor monitor ) {
@@ -969,7 +970,7 @@ public IStatus runInUIThread(IProgressMonitor monitor) {
969970 };
970971 updateJob .setSystem (true );
971972 updateJob .schedule (getLongOperationTime ());
972-
973+ return updateJob ;
973974 }
974975
975976 /**
@@ -1072,11 +1073,19 @@ public void run(boolean fork, boolean cancelable, IRunnableWithProgress runnable
10721073 // Backward compatible code.
10731074 final ProgressMonitorJobsDialog dialog = new ProgressMonitorJobsDialog (
10741075 ProgressManagerUtil .getDefaultParent ());
1075- dialog .setOpenOnRun (false );
1076- if (!shouldRunInBackground ()) {
1077- scheduleProgressMonitorJob (dialog );
1076+ if (shouldRunInBackground ()) {
1077+ dialog .setOpenOnRun (false );
1078+ dialog .run (fork , cancelable , runnable );
1079+ } else {
1080+ Job showDialogJob = scheduleProgressMonitorJob (dialog );
1081+ try {
1082+ dialog .run (fork , cancelable , runnable );
1083+ } finally {
1084+ // In case the dialog hasn't popped up yet, cancel it so it doesn't pop up after
1085+ // the operation finishes or unwinds with an exception.
1086+ showDialogJob .cancel ();
1087+ }
10781088 }
1079- dialog .run (fork , cancelable , runnable );
10801089 return ;
10811090 }
10821091
0 commit comments