Class ProgressWorker<T,V>

java.lang.Object
javax.swing.SwingWorker<T,V>
is.codion.swing.common.model.worker.ProgressWorker<T,V>
Type Parameters:
T - the type of result this ProgressWorker produces.
V - the type of intermediate result produced by this ProgressWorker
All Implemented Interfaces:
Runnable, Future<T>, RunnableFuture<T>

public final class ProgressWorker<T,V> extends SwingWorker<T,V>

A SwingWorker implementation. Instances of this class are not reusable.

Note that this implementation does NOT coalesce progress reports or intermediate result publishing, but simply pushes those directly to the onProgress and onPublish handlers on the Event Dispatch Thread.

The onStarted handler is guaranteed to be called on the Event Dispatch Thread before the background task executes, and the onDone handler is guaranteed to be called after the background task completes.

 ProgressWorker.builder(this::performTask)
   .onStarted(this::displayDialog)
   .onDone(this::closeDialog)
   .onResult(this::handleResult)
   .onProgress(this::displayProgress)
   .onPublish(this::publishMessage)
   .onCancelled(this::displayCancelledMessage)
   .onException(this::displayException)
   .execute();
See Also: