Class BackgroundTaskBuilder<T>
java.lang.Object
cz.masci.springfx.mvci.util.builder.BackgroundTaskBuilder<T>
- Type Parameters:
T- the type of the background task result
This builder prepares
Task with most events handlers.
Basic usage
BackgroundTaskBuilder.task(() -> "Hello").start();
All event handlers
BackgroundTaskBuilder
.task(() -> "Hello")
.onCancelled(task -> System.out.println("Task has been cancelled"))
.onFailed(task -> System.out.println("Task failed with an error: " + task.getException()))
.onRunning(task -> System.out.println("Task has been started"))
.onScheduled(task -> System.out.println("Task has been scheduled"))
.onSucceeded(taskResult -> System.out.println("Task ended with result: " + taskResult))
.postGuiCall(() -> System.out.println("This part is running in JavaFX thread"))
.start();
Post GUI Call
postGuiCall is called when Task succeeded, cancelled or failed after appropriate onXXX method is called.-
Method Summary
Modifier and TypeMethodDescriptionjavafx.concurrent.Task<T>build()onCancelled(Consumer<javafx.concurrent.Task<T>> onCancelled) onScheduled(Consumer<javafx.concurrent.Task<T>> onScheduled) onSucceeded(Consumer<T> onSucceeded) postGuiCall(Runnable postGuiCall) voidstart()static <T> BackgroundTaskBuilder<T>static <T> BackgroundTaskBuilder<T>task(org.apache.commons.lang3.function.FailableFunction<javafx.concurrent.Task<T>, T, ? extends Exception> functionalTask)
-
Method Details
-
task
-
task
public static <T> BackgroundTaskBuilder<T> task(org.apache.commons.lang3.function.FailableFunction<javafx.concurrent.Task<T>, T, ? extends Exception> functionalTask) -
start
public void start() -
build
-
postGuiCall
-
onCancelled
-
onFailed
-
onRunning
-
onScheduled
-
onSucceeded
-