*[[FAQ What are IWorkspaceRunnable, IRunnableWithProgress, and WorkspaceModifyOperation?]]

*[[FAQ What are IWorkspaceRunnable, IRunnableWithProgress, and WorkspaceModifyOperation?]]

−

<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>

+

{{Template:FAQ_Tagline}}

Latest revision as of 14:54, 17 June 2006

Every time resources in the workspace change, a resource change notification is
broadcast, and autobuild gets a chance to run. This can become very costly
if you are making several changes in succession to the workspace. To avoid
these extra builds and notifications, it is very important that you batch
all of your workspace changes into a single workspace operation. It
is easy to accidentally cause extra builds if you arent very careful about batching
your changes. For example, even creating and modifying attributes on
IMarker objects will cause separate resource change events if
they are not batched.

Two different mechanisms are available for batching changes. To
run a series of changes in the current thread, use IWorkspaceRunnable.
Here is an example of a workspace runnable that creates two folders:

The other mechanism for batching resource changes is a WorkspaceJob.
Introduced in Eclipse 3.0, this mechanism is the asynchronous equivalent of IWorkspaceRunnable.
When you create and schedule a workspace job, it will perform the changes in a background
thread and then cause a single resource change notification and autobuild to occur. Here
is sample code using a workspace job: