void (@NotNull ProgressIndicator indicator) { boolean failed = false; try { new ProgressIndicatorListener() { @Override public void cancelled() { myProgressIndicator.cancel(); } }.installToProgressIfPossible(indicator); ProgressIndicatorEx relayToVisibleIndicator = new RelayUiToDelegateIndicator(indicator); myProgressIndicator.addStateDelegate(relayToVisibleIndicator); try { myProgressIndicator.checkCanceled(); myTask.doDownload(myProgressIndicator); } finally { myProgressIndicator.removeStateDelegate(relayToVisibleIndicator); } // make sure VFS has the right image of our SDK to avoid empty SDK from being created VfsUtil.markDirtyAndRefresh(false, true, true, new File(myTask.getPlannedHomeDir())); //update the pending SDKs onSdkDownloadCompletedSuccessfully(); } catch (Throwable e) { failed = true; if (!myProgressIndicator.isCanceled() && !(e instanceof ControlFlowException)) { handleDownloadError(type, title, e); } } finally { // dispose our own state disposeNow(!failed); } }