void () { // Running sync task on pooled thread from EDT w/o event polling can lead to deadlock if pooled thread will try to invokeAndWait. BooleanSupplier assertion = ApplicationManager.getApplication().isDispatchThread() ? () -> ApplicationManager.getApplication().isWriteIntentLockAcquired() : () -> !ApplicationManager.getApplication().isWriteIntentLockAcquired(); TestTask task = new TestTask().withAssertion(assertion); ProgressResult<?> result = computeAssertingExceptionConditionally( myOnEdt && myReleaseIWLockOnRun, () -> new ProgressRunner<>(task) .onThread(ProgressRunner.ThreadToUse.POOLED) .withProgress(new EmptyProgressIndicator()) .sync() .submitAndGet()); if (result == null) return; assertFalse(result.isCanceled()); assertNull(result.getThrowable()); task.assertFinished(); }