Jump to: navigation, search

FAQ Why should I use the new progress service?

Revision as of 15:21, 14 March 2006 by Claffra (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Eclipse 3.0 introduced a central new workbench progress service. This service combines the advantages of busy cursors and Progress dialogs by switching from one to the other, depending on the length of the long-running task. The service also handles a further wrinkle caused by the introduction of background jobs. It is now possible for a short-running task to become blocked by a longer-running job running in the background, owing to contention for various resources. When this happens, the progress service opens a richer Progress dialog with a details area showing all running background jobs. This allows the user to see what

is happening and to cancel either the foreground or the background task, depending on which is more important.


The service is used much like the SWT BusyIndicator. Simply pass an IRunnableWithProgress instance to the busyCursorWhile method. The UI will prevent further user input and report progress feedback until the runnable completes. Note that the runnable executes in a non-UI thread, so you will have to use asyncExec or syncExec to execute any code within the runnable that requires access to UI widgets:

   IWorkbench wb = PlatformUI.getWorkbench();
   IProgressService ps = wb.getProgressService();
   ps.busyCursorWhile(new IRunnableWithProgress() {
      public void run(IProgressMonitor pm) {
         ... do some long running task
      }
   });


This progress service was introduced to unify a number of progress-reporting mechanisms in Eclipse 2.1. JFace provides a Progress Monitor dialog, SWT provides a busy indicator, and the workbench provides a progress indicator on the status line. Each of these mechanisms has its own advantages and disadvantages. The busy cursor is the least obtrusive and works well for tasks that typically take a second or less. The Progress dialog provides much more information and allows the user to cancel but is visually distracting, especially on short tasks as it pops up over the user’s work. The status line progress monitor is a bit less obtrusive but doesn’t give an obvious indication that the UI is not accepting further input, and the space for presenting progress indication is very constrained. The new progress service tries to achieve a balance by automatically adapting between a busy cursor and a dialog, depending on the situation.


See Also:

FAQ_Why_do_I_get_an_invalid_thread_access_exception?

FAQ_How_do_I_switch_from_using_a_Progress_dialog_to_the_Progress_view?

FAQ_Actions,_commands,_operations,_jobs:_What_does_it_all_mean?

[[FAQ_What_are_%3Ctt%3EIWorkspaceRunnable%3C%2Ftt%3E%2C_%3Ctt%3EIRunnableWithProgress%3C%2Ftt%3E%2C_and_%3Ctt%3EWorkspaceModifyOperation%3C%2Ftt%3E%3F]]


This FAQ was originally published in Official Eclipse 3.0 FAQs. Copyright 2004, Pearson Education, Inc. All rights reserved. This text is made available here under the terms of the Eclipse Public License v1.0.