Update label from nested function called from Task API in JavaFX

Viewed 334

I am performing some background task using this class

class Download extends Task{
     protected Object call() throws Exception {
        try {
            updateMessage("Establishing Connection");
            DownloadHelper downloadHelper = new DownloadHelper();
            downloadHelper.performTask();
            return null;
        } catch (IOException | ParseException ex) {
            logger.error(ExceptionUtils.getStackTrace(ex));
            throw ex;
        }
    }
}

This Task in turn calls DownloadHelper to perform some task.

class DownloadHelper{
    public DownloadHelper(){
    }

    public void performTask(){
    ----
    ----
    }
}

Is there a way to update the status message of the Task API (updateMessage()) from the DownloadHelper class.?

1 Answers
Related