void (@NotNull final Project project, @NotNull String text, @Nullable File workingDir) { PlaybackRunnerExtended runner = new PlaybackRunnerExtended(text, new CommandLogger(), project); runner.setScriptDir(workingDir); runner.setCommandStartStopProcessor(myScriptRunnerReporter != null ? myScriptRunnerReporter : SystemProperties.getBooleanProperty(ReporterCommandAsTelemetrySpan.USE_SPAN_WRAPPER_FOR_COMMAND, false) ? new ReporterCommandAsTelemetrySpan(new ReporterWithTimer()) : new ReporterWithTimer()); Task.Backgroundable task = new Task.Backgroundable(project, PerformanceTestingBundle.message("task.title.executing.performance.script")) { @Override public void run(@NotNull ProgressIndicator indicator) { CountDownLatch countDownLatch = new CountDownLatch(1); runner.run().whenComplete((o, throwable) -> { countDownLatch.countDown(); }); final ScheduledExecutorService myExecutor = ConcurrencyUtil.newSingleScheduledThreadExecutor("Performance plugin script runner"); myExecutor.scheduleWithFixedDelay(() -> { if (indicator.isCanceled()) { runner.stop(); } }, 0, 100, TimeUnit.MILLISECONDS); try { countDownLatch.await(); } catch (InterruptedException ignored) { } myExecutor.shutdownNow(); } }; ProgressManager.getInstance().run(task); }