Jump to: navigation, search

Difference between revisions of "FAQ Why should I use the new progress service?"

 
m
Line 8: Line 8:
 
contention for various resources.  When this happens, the progress
 
contention for various resources.  When this happens, the progress
 
service opens a richer Progress dialog with a details area showing all
 
service opens a richer Progress dialog with a details area showing all
running background jobs. This allows the user to see what
+
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.
 
+
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 <tt>BusyIndicator</tt>.  Simply pass
 
The service is used much like the SWT <tt>BusyIndicator</tt>.  Simply pass
Line 22: Line 17:
 
have to use <tt>asyncExec</tt> or <tt>syncExec</tt> to execute
 
have to use <tt>asyncExec</tt> or <tt>syncExec</tt> to execute
 
any code within the runnable that requires access to UI widgets:
 
any code within the runnable that requires access to UI widgets:
 +
 
<pre>
 
<pre>
 
   IWorkbench wb = PlatformUI.getWorkbench();
 
   IWorkbench wb = PlatformUI.getWorkbench();
Line 31: Line 27:
 
   });
 
   });
 
</pre>
 
</pre>
 
  
 
This progress service was introduced to unify a number of  
 
This progress service was introduced to unify a number of  
Line 47: Line 42:
 
progress service tries to achieve a balance by automatically adapting
 
progress service tries to achieve a balance by automatically adapting
 
between a busy cursor and a dialog, depending on the situation.
 
between a busy cursor and a dialog, depending on the situation.
 
  
 
== See Also: ==
 
== See Also: ==
 
+
*[[FAQ_Why_do_I_get_an_invalid_thread_access_exception%3F]]
[[FAQ_Why_do_I_get_an_invalid_thread_access_exception%3F]]
+
*[[FAQ_How_do_I_switch_from_using_a_Progress_dialog_to_the_Progress_view%3F]]
 
+
*[[FAQ_Actions%2C_commands%2C_operations%2C_jobs%3A_What_does_it_all_mean%3F]]
[[FAQ_How_do_I_switch_from_using_a_Progress_dialog_to_the_Progress_view%3F]]
+
*[[FAQ What are IWorkspaceRunnable, IRunnableWithProgress, and WorkspaceModifyOperation?]]
 
+
[[FAQ_Actions%2C_commands%2C_operations%2C_jobs%3A_What_does_it_all_mean%3F]]
+
 
+
[[FAQ_What_are_%3Ctt%3EIWorkspaceRunnable%3C%2Ftt%3E%2C_%3Ctt%3EIRunnableWithProgress%3C%2Ftt%3E%2C_and_%3Ctt%3EWorkspaceModifyOperation%3C%2Ftt%3E%3F]]
+
  
 
<hr><font size=-2>This FAQ was originally published in [http://www.eclipsefaq.org Official Eclipse 3.0 FAQs]. Copyright 2004, Pearson Education, Inc. All rights reserved. This text is made available here under the terms of the [http://www.eclipse.org/legal/epl-v10.html Eclipse Public License v1.0].</font>
 
<hr><font size=-2>This FAQ was originally published in [http://www.eclipsefaq.org Official Eclipse 3.0 FAQs]. Copyright 2004, Pearson Education, Inc. All rights reserved. This text is made available here under the terms of the [http://www.eclipse.org/legal/epl-v10.html Eclipse Public License v1.0].</font>

Revision as of 22:16, 29 May 2006

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:


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.