edit this page - page history - about editing

Force an IProject file system refresh in Eclipse


The problem with the IProject.refresh() method is that it is non-blocking; that is, it may be refreshing the file system, but you won't know when it is done. Here is a little helping code to force the current thread to wait until it's complete:

class HaltProgressMonitor extends NullProgressMonitor {
  public void setCanceled(boolean cancelled) {
    isDone = true;  // bail early

  private boolean isDone = false;
  public synchronized boolean isDone() {
    return isDone;

  public void done() {
    isDone = true;

IProject project = ...;
HaltProgressMonitor m = new HaltProgressMonitor();
project.refreshLocal(IResource.DEPTH_INFINITE, m);
try {
  while (!m.isDone()) {
} catch (InterruptedException e) {
  // do something

Categories: Eclipse | Article | Code Sample
edit this page - what links to here? - page history - top
Last edited by jevon jevon 127 months ago