MCPcopy Create free account
hub / github.com/FabricMC/Matcher / runAsyncTask

Method runAsyncTask

src/main/java/matcher/gui/Gui.java:482–499  ·  view source on GitHub ↗
(Callable<T> task)

Source from the content-addressed store, hash-verified

480 }
481
482 public static <T> CompletableFuture<T> runAsyncTask(Callable<T> task) {
483 Task<T> jfxTask = new Task<T>() {
484 @Override
485 protected T call() throws Exception {
486 return task.call();
487 }
488 };
489
490 CompletableFuture<T> ret = new CompletableFuture<T>();
491
492 jfxTask.setOnSucceeded(event -> ret.complete(jfxTask.getValue()));
493 jfxTask.setOnFailed(event -> ret.completeExceptionally(jfxTask.getException()));
494 jfxTask.setOnCancelled(event -> ret.cancel(false));
495
496 threadPool.execute(jfxTask);
497
498 return ret;
499 }
500
501 public void runProgressTask(String labelText, Consumer<DoubleConsumer> task) {
502 runProgressTask(labelText, task, null, null);

Callers 2

onSelectMethod · 0.95
updateMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected