void () { ThreadingAssertions.assertEventDispatchThread(); if (currentState != State.INITIALIZED) { throw new IllegalStateException("Task should be initialized with init() method"); } if (requestInfo == null) { throw new IllegalStateException("Invalid request for task beginning"); } currentState = State.STARTED; beforeRun(); progressIndicator = new ProgressIndicatorBase(); final RequestInfo requestInfoCopy = cloneRequestInfo(requestInfo); ApplicationManager.getApplication().executeOnPooledThread( () -> runWithWriteActionPriority( progressIndicator, parentDisposable, () -> { ResultData resultData = null; try { resultData = processRequest(requestInfoCopy); } finally { // Back to GUI thread for submitting result final ResultData finalResult = resultData; ApplicationManager.getApplication().invokeLater(() -> resultReady(finalResult)); } })); }