void (ProgressIndicator indicator) { indicator.setIndeterminate(false); int iterations = 3000; indicator.setText("In background thread"); for (int i = 0; i < iterations; i++) { TimeoutUtil.sleep(1); ApplicationManager.getApplication().assertWriteAccessAllowed(); indicator.setFraction(((double)i + 1) / ((double)iterations)); indicator.setText2(String.valueOf(i)); ProgressManager.checkCanceled(); } }