void () { final AtomicBoolean canceled = new AtomicBoolean(); final ProgressIndicatorBase indicator = new ProgressIndicatorBase(); AtomicReference<CompletableFuture<?>> future = new AtomicReference<>(); future.set(ProgressIndicatorUtils.scheduleWithWriteActionPriority(indicator, new ReadTask() { @Override public Continuation performInReadAction(@NotNull ProgressIndicator indicator) throws ProcessCanceledException { return new Continuation(() -> { assertFalse(future.get().isDone()); WriteAction.run(() -> { }); // when I start write action from the continuation, the read task must not cancel }); } @Override public void onCanceled(@NotNull ProgressIndicator indicator) { canceled.set(true); fail(); } })); while (!future.get().isDone()) { UIUtil.dispatchAllInvocationEvents(); } assertFalse(canceled.get()); }