boolean (ExternalSystemTaskNotificationListener @NotNull ... listeners) { ExternalSystemTaskState currentTaskState = getState(); if (currentTaskState.isStopped()) return true; ExternalSystemProgressNotificationManager progressManager = ExternalSystemProgressNotificationManager.getInstance(); for (ExternalSystemTaskNotificationListener listener : listeners) { progressManager.addNotificationListener(getId(), listener); } if (!compareAndSetState(currentTaskState, ExternalSystemTaskState.CANCELING)) return false; try { return doCancel(); } catch (NotSupportedException e) { NotificationData notification = new NotificationData(ExternalSystemBundle.message("progress.cancel.failed"), e.getMessage(), NotificationCategory.WARNING, NotificationSource.PROJECT_SYNC); notification.setBalloonNotification(true); ExternalSystemNotificationManager.getInstance(getIdeProject()).showNotification(getExternalSystemId(), notification); } catch (Throwable e) { setState(ExternalSystemTaskState.CANCELLATION_FAILED); myError.set(e); LOG.warn(e); } return false; }