Skip Navigation

About Long-running Operations in a Plug-in

A long-running operation is a background job or process that runs in Sabre Red 360 for an extended period of time.

Developers typically implement long-running operations when their plug-in communicates with the server for access to the network or files.

You can use all functionality and methods in the Eclipse public Jobs API to create long-running operations in your plug-ins. The Eclipse Jobs API supports the execution of a long-running job as a background process. With this API, you can also provide feedback about the progress of the background process in a dialog that you display to end-users in Sabre Red 360. All you do is add the Job implementation into your existing code.

A separate thread outside the UI is required because Sabre Red 360 permits only one thread to update the UI. This thread is called the UI thread. The UI thread creates the org.eclipse.swt.widgets.Display, which executes all events in this thread sequentially. If another thread tries to update the UI, you will receive the org.eclipse.swt.SWTException: Invalid thread access exception. Therefore, in order to make your plug-in compatible with Sabre Red 360 and to avoid freezing the UI, you are required to execute a long-running operation in a separate thread.

For details about the Eclipse Jobs API and examples of use, consult the following article:

The information in this topic and the com.sabre.redapp.example.longrunning sample plug-in are based on the first occurrence of Example  2 in this article.

Simple Code Example of a Long-running Operation

The following code is a simple and frequently-used example of a long-running operation.

final Job job = new Job("Long Running Job") {
protected IStatus run(IProgressMonitor monitor) {
            // We are performing a long-running operation
            // For example, communication to a server
            return Status.OK_STATUS;

This sample code does the following:

  • Creates a new job with the name Long Running Job

  • Uses IProgressMonitor to provide feedback to the end-user about the status of the job and to check for cancellation of the job

  • Returns an OK status if the job completes successfully

  • Sets the long-running operation as a user job

Dependencies, Extension Points, and Classes

Whether you are customizing a long-running operation or working with the sample plug-in in Sabre Red 360 Software Development Kit and this topic, Eclipse has defined a dependency and a class that are required to create a long-running operation. These requirements are listed below.

  • org.eclipse.core.runtime plug-in. This dependency provides the Job class.

  • Job class. This class lets clients execute code in a separate thread as a background process.