| <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><HTML> |
| <HEAD> |
| <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-1"> |
| <META HTTP-EQUIV="Content-Style-Type" CONTENT="text/css"> |
| |
| <LINK REL="STYLESHEET" HREF="../book.css" CHARSET="ISO-8859-1" TYPE="text/css"> |
| <TITLE> |
| Long-running operations |
| </TITLE> |
| |
| <link rel="stylesheet" type="text/css" HREF="../book.css"> |
| </HEAD> |
| <BODY BGCOLOR="#ffffff"> |
| <H2> |
| Long-running operations</H2> |
| <P > |
| The <b><a href="../reference/api/org/eclipse/jface/operation/package-summary.html"> org.eclipse.jface.operations</a></b> package defines interfaces for |
| long-running operations that require progress indicators or allow user cancellation of the operation.</P> |
| |
| <H3>Runnables and progress</H3> |
| <P > |
| The platform core runtime defines a common interface, <b><a href="../reference/api/org/eclipse/core/runtime/IProgressMonitor.html">IProgressMonitor</a></b>, which is used to report progress to the user while long running operations are in progress. The |
| client can provide a monitor as a parameter in many platform API methods when it |
| is important to show progress to the user.</P> |
| <P >JFace defines more specific interfaces for objects that implement the user interface for a progress monitor. </P> |
| <P > |
| <b><a href="../reference/api/org/eclipse/jface/operation/IRunnableWithProgress.html"> IRunnableWithProgress</a></b> |
| is the interface for a long-running operation. The <b>run</b> |
| method for this interface has an <b><a href="../reference/api/org/eclipse/core/runtime/IProgressMonitor.html">IProgressMonitor</a> |
| </b>parameter that is used to report progress and check for user cancelation.</P> |
| <P ><a href="../reference/api/org/eclipse/jface/operation/IRunnableContext.html"><b>IRunnableContext</b></a> |
| is the interface for the different places in the UI where progress can be |
| reported. Classes that implement this interface may choose to use different techniques for showing progress and running the operation. |
| For example, <b><a href="../reference/api/org/eclipse/jface/dialogs/ProgressMonitorDialog.html">ProgressMonitorDialog</a></b> |
| implements this interface by showing a progress dialog. <b><a href="../reference/api/org/eclipse/ui/IWorkbenchWindow.html">IWorkbenchWindow</a></b> |
| implements this interface by showing progress in the workbench window's status |
| line. <a href="../reference/api/org/eclipse/jface/wizard/WizardDialog.html"><b>WizardDialog</b></a> |
| implements this interface to show long running operations inside the wizard |
| status line.</P> |
| <i><blockquote>Note: The workbench UI provides additional support for |
| operations in <b><a href="../reference/api/org/eclipse/ui/actions/WorkspaceModifyOperation.html">WorkspaceModifyOperation</a></b>. |
| This class simplifies the implementation of long-running operations that modify |
| the workspace. It maps between <a href="../reference/api/org/eclipse/jface/operation/IRunnableWithProgress.html"><b>IRunnableWithProgress</b></a> |
| and <a href="../reference/api/org/eclipse/core/resources/IWorkspaceRunnable.html"><b>IWorkspaceRunnable</b></a>. |
| See the javadoc for further detail.</blockquote></i> |
| |
| |
| <H3> |
| Modal operations</H3> |
| <P > |
| The <b><a href="../reference/api/org/eclipse/jface/operation/ModalContext.html"> ModalContext</a></b> class is provided to run an operation that is modal from the client code's perspective. |
| It is used inside the different implementations of <a href="../reference/api/org/eclipse/jface/operation/IRunnableContext.html"><b>IRunnableContext</b></a>. |
| If your plug-in needs to wait on the completion of a long-running operation before continuing |
| execution, <b><a href="../reference/api/org/eclipse/jface/operation/ModalContext.html">ModalContext</a></b> can be used to accomplish this while still keeping the user interface responsive.</P> |
| <P > |
| When you run an operation in a modal context, you can choose to fork the operation in a different thread. If |
| <b>fork</b> is false, the operation will be run in the |
| calling thread. If <b>fork</b> is true, the |
| operation will be run in a new thread, the calling thread will be blocked, and |
| the UI event loop will be run until the operation terminates. </P> |
| <P > |
| For more information on the UI event loop, see <a HREF="swt_threading.htm" CLASS="XRef"> Threading issues for clients</a>.</P> |
| |
| <p><a href="../hglegal.htm"><img border="0" src="../ngibmcpy.gif" alt="Copyright IBM Corporation and others 2000, 2003." border="0" width="324" height="14"></a></p> |
| |
| </BODY> |
| </HTML> |