private void run(final @NotNull WorkerThreadRequest threadRequest) {
    try {
      DumbModeAccessType.RELIABLE_DATA_ONLY.ignoreDumbMode(() -> ProgressManager.getInstance().runProcess(() -> {
        while (true) {
          try {
            if (threadRequest.isStopRequested()) {
              break;
            }

            final WorkerThreadRequest currentRequest = getCurrentRequest();
            if (currentRequest != threadRequest) {
              String message = "Expected " + threadRequest + " instead of " + currentRequest + " closed=" + myEvents.isClosed();
              LOG.error(message, new IllegalStateException(message), ThreadDumper.dumpThreadsToString());
              break; // ensure events are processed by one thread at a time
            }

            doProcessEvent(myEvents.get());
          }
          catch (VMDisconnectedException | EventQueueClosedException ignored) {
            break;
          }
          catch (ProcessCanceledException ignored) {
          }
          catch (CompletionException e) {
            if (e.getCause() instanceof VMDisconnectedException) {
              break;
            }
            reportCommandError(e);
          }
          catch (RuntimeException e) {
            if (e.getCause() instanceof InterruptedException) {
              break;
            }
            reportCommandError(e);
          }
          catch (Throwable e) {
            reportCommandError(e);
          }
        }
      }, threadRequest.myProgressIndicator));
    }
    finally {
      // ensure that all scheduled events are processed
      if (threadRequest == getCurrentRequest()) {
        processRemaining();
      }

      LOG.debug("Request " + this + " exited");
    }
  }
private void run(final @NotNull WorkerThreadRequest threadRequest)