class RunningLongTask<V> implements Callable<V> {

        private final LongTask task;
        private final Runnable runnable;
        private final Callable<V> callable;
        private final LongTaskErrorHandler errorHandler;
        private Future<V> future;
        private ProgressTicket progress;

        public RunningLongTask(LongTask task, Runnable runnable, String taskName, LongTaskErrorHandler errorHandler) {
            this.task = task;
            this.runnable = runnable;
            this.callable = null;
            this.errorHandler = errorHandler;
            init(taskName);
        }

        public RunningLongTask(LongTask task, Callable<V> callable, String taskName, LongTaskErrorHandler errorHandler) {
            this.task = task;
            this.runnable = null;
            this.callable = callable;
            this.errorHandler = errorHandler;
            init(taskName);
        }

        private void init(String taskName) {
            ProgressTicketProvider progressProvider = Lookup.getDefault().lookup(ProgressTicketProvider.class);
            if (progressProvider != null) {
                this.progress = progressProvider.createTicket(taskName, () -> {
                    LongTaskExecutor.this.cancel();
                    return true;
                });
                if (task != null) {
                    task.setProgressTicket(progress);
                }
            }
        }

        @Override
        public V call() {<FILL_FUNCTION_BODY>}

        public boolean cancel() {
            if (task != null) {
                return task.cancel();
            }
            return false;
        }
    }

            if (task != null && progress != null) {
                progress.start();
            }
            currentTask = this;
            V result = null;
            try {
                if (runnable != null) {
                    runnable.run();
                } else if (callable != null) {
                    result = callable.call();
                    if (!inBackground) {
                        future = CompletableFuture.completedFuture(result);
                    }
                }

                currentTask = null;

                finished(this);
                if (progress != null) {
                    progress.finish();
                }
            } catch (Throwable e) {
                LongTaskErrorHandler err = errorHandler;
                if (progress != null) {
                    progress.finish();
                }
                currentTask = null;
                if (err != null) {
                    err.fatalError(e);
                } else if (defaultErrorHandler != null) {
                    defaultErrorHandler.fatalError(e);
                } else {
                    Logger.getLogger("").log(Level.SEVERE, "", e);
                }
                if (!inBackground) {
                    future = CompletableFuture.failedFuture(e);
                } else if (callable != null) {
                    if (e instanceof RuntimeException) {
                        throw (RuntimeException) e;
                    }
                    throw new RuntimeException(e);
                }
            }

            return result;
        
<no_super_class>