Figure 7-9. The WorkerAndTaskExample program after the task succeeded
If, instead of letting the task finish normally, we click the Cancel button, the task will finish immediately and the screenshot in Figure 7-10 results. Notice that the State field has the value CANCELLED now. The Value field contains the string we passed to the updateValue() method when the task was cancelled. When we detect that the task is cancelled, we have two choices of exiting from the method body. In the program in Listing 7-7, we chose to update the Value and return from the method. We could also have chosen to exit from the method body by throwing a RuntimeException ...
Get Pro JavaFX 8 now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.