You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/modules/flow-ui/pages/background-tasks.adoc
+9-7Lines changed: 9 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -22,7 +22,7 @@ Closing the view interrupts the tasks associated with it. Besides, the task is i
22
22
23
23
. Run the task by invoking the `execute()` method of `BackgroundTaskHandler`.
24
24
25
-
[WARNING]
25
+
[CAUTION]
26
26
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.
27
27
28
28
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`,
54
54
[[run]]
55
55
=== run()
56
56
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.
58
60
59
61
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.
60
62
@@ -63,27 +65,27 @@ You can also check whether the task was interrupted with `cancel()` using the `i
63
65
[[canceled]]
64
66
=== canceled()
65
67
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`.
67
69
68
70
[[progress]]
69
71
=== progress()
70
72
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.
72
74
73
75
[[done]]
74
76
=== done()
75
77
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.
77
79
78
80
[[handle-timeout-exception]]
79
81
=== handleTimeoutException()
80
82
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.
82
84
83
85
[[handle-exception]]
84
86
=== handleException()
85
87
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.
0 commit comments