Skip to content

Commit 4e459e4

Browse files
committed
Extend description of BackgroundTask methods #644
1 parent 40c929c commit 4e459e4

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

content/modules/flow-ui/pages/background-tasks.adoc

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Closing the view interrupts the tasks associated with it. Besides, the task is i
2222

2323
. Run the task by invoking the `execute()` method of `BackgroundTaskHandler`.
2424

25-
[WARNING]
25+
[CAUTION]
2626
Do not read or update the state of UI components and data containers in `BackgroundTask.run()` method; use `done()`, `progress()`, and `canceled()` callback methods instead. If you try to set a value to a UI component from a background thread, `IllegalConcurrentAccessException` is thrown.
2727

2828
Below is an example of running a background task and tracking its progress using the xref:vc/components/progressBar.adoc[progressBar] component:
@@ -54,7 +54,9 @@ Detailed information about methods is provided in Javadocs for `BackgroundTask`,
5454
[[run]]
5555
=== run()
5656

57-
This method implements the task. It is invoked in a separate working thread to perform the task.
57+
This method is executed in a separate background thread to perform the task.
58+
59+
CAUTION: Do not read or update the state of UI components and data containers in this method.
5860

5961
The method should support external interruptions. To ensure this, check the `TaskLifeCycle.isInterrupted()` flag periodically during long processes and stop execution when needed. Additionally, you should not silently discard `InterruptedException` (or any other exception) -- instead, you should either exit the method correctly or not handle the exception at all.
6062

@@ -63,27 +65,27 @@ You can also check whether the task was interrupted with `cancel()` using the `i
6365
[[canceled]]
6466
=== canceled()
6567

66-
This method is invoked in UI thread only during a controlled cancellation of a task, for example, when the `cancel()` method is invoked in the `TaskHandler`.
68+
This method is invoked in a thread that has access to UI components only during a controlled cancellation of a task, for example, when the `cancel()` method is invoked in the `TaskHandler`.
6769

6870
[[progress]]
6971
=== progress()
7072

71-
This method is invoked in the UI thread when the progress value changes. For example, after calling the `taskLifeCycle.publish()` method.
73+
This method is invoked in a thread that has access to UI components when the progress value changes. For example, after calling the `taskLifeCycle.publish()` method.
7274

7375
[[done]]
7476
=== done()
7577

76-
This method is invoked in UI thread once the task is complete.
78+
This method is invoked in a thread that has access to UI components once the task is complete.
7779

7880
[[handle-timeout-exception]]
7981
=== handleTimeoutException()
8082

81-
This method is invoked in UI thread when the task timeout expires. If the window where the task is running closes, the task is stopped without notification.
83+
This method is invoked in a thread that has access to UI components when the task timeout expires. If the window where the task is running closes, the task is stopped without notification.
8284

8385
[[handle-exception]]
8486
=== handleException()
8587

86-
This method is invoked in UI thread when any exceptions occur.
88+
This method is invoked in a thread that has access to UI components when any exceptions occur.
8789

8890
[[notes-and-tips]]
8991
== Notes & Tips

0 commit comments

Comments
 (0)