@Override
    public <E extends Throwable> void run(final @NotNull ThrowableRunnable<E> action) throws E {
      Application application = ApplicationManager.getApplication();
      boolean dispatchThread = application.isDispatchThread();

      if (!dispatchThread && application.isReadAccessAllowed()) {
        throw new IllegalStateException("Must not start write action from within read action in the other thread - deadlock is coming");
      }

      AtomicReference<E> thrown = new AtomicReference<>();
      if (dispatchThread) {
        thrown.set(doRunWriteCommandAction(action));
      }
      else {
        try {
          ApplicationManager.getApplication().invokeAndWait(() -> thrown.set(doRunWriteCommandAction(action)));
        }
        catch (ProcessCanceledException ignored) {
        }
      }
      if (thrown.get() != null) {
        throw thrown.get();
      }
    }
@Override
    public <E extends Throwable> void run(final @NotNull ThrowableRunnable<E> action)