## Long-running operations

The org.eclipse.jface.operations package defines interfaces for long-running operations that require progress indicators or allow user cancellation of the operation.

### Runnables and progress

The platform runtime defines a common interface, IProgressMonitor, 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.

JFace defines more specific interfaces for objects that implement the user interface for a progress monitor.

IRunnableWithProgress is the interface for a long-running operation. The run method for this interface has an IProgressMonitor parameter that is used to report progress and check for user cancelation.

IRunnableContext 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, ProgressMonitorDialog implements this interface by showing a progress dialog. IWorkbenchWindow implements this interface by showing progress in the workbench window's status line. WizardDialog implements this interface to show long running operations inside the wizard status line.

> Note: The workbench UI provides additional support for operations in WorkspaceModifyOperation. This class simplifies the implementation of long-running operations that modify the workspace. It maps between IRunnableWithProgress and IWorkspaceRunnable. See the javadoc for further detail.

### Modal operations

The ModalContext class is provided to run an operation that is modal from the client code's perspective. It is used inside the different implementations of IRunnableContext. If your plug-in needs to wait on the completion of a long-running operation before continuing execution, ModalContext can be used to accomplish this while still keeping the user interface responsive.

When you run an operation in a modal context, you can choose to fork the operation in a different thread. If fork is false, the operation will be run in the calling thread. If fork 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.

For more information on the UI event loop, see Threading issues for clients.

### IProgressService

New in Eclipse 3.0 is support for long-running operations without having to worry about which runnable context to use run a long running operation. In addition the new IProgressService APIs provide progress dialogs that have details areas that allow the user to have control over background operations that may be blocking the given operation. See the Workbench Concurrency Support documentation.