background_processes.md: Clarify ProgressIndicator vs ProgressManager

This commit is contained in:
Karol Lewandowski 2025-02-12 16:54:45 +01:00
parent 1dd35f787e
commit af6e2b55cc

View File

@ -165,17 +165,22 @@ Use inspection <control>Plugin DevKit | Code | Cancellation check in loops</cont
### Tracking Progress
Displaying progress to the user is achieved with `ProgressIndicator` or `ProgressManager` if no indicator instance is available in the current context.
Displaying progress to the user is achieved with:
- `ProgressIndicator` - if available in the current context
- `ProgressManager` - if no indicator instance is available in the current context
To report progress, use the following methods:
- `setText(String)` sets text above the progress bar
- `setText2(String)` sets text under the progress bar
To report progress with `ProgressIndicator`, use the following methods:
- `setText(String)` sets the progress text displayed above the progress bar
- `setText2(String)` sets the progress details text displayed under the progress bar
- `setFraction(double)` sets the progress fraction: a number between 0.0 (nothing) and 1.0 (all) reflecting the ratio of work that has already been done.
Only works for determinate indicator.
The fraction should provide the user with an estimation of the time left.
If this is impossible, consider making the progress indeterminate.
- `setIndeterminate(boolean)` marks the progress indeterminate (for processes that can't estimate the amount of work to be done) or determinate (for processes that can display the fraction of the work done using `setFraction(double)`).
`ProgressManager` allows for reporting progress texts through `progress()`/`progress2()` methods, which are counterparts of `ProgressIndicator.setText()`/`setText2()`.
In addition, it exposes the `ProgressIndicator.getProgressIndicator()` method for getting an indicator instance associated with the current thread.
## `ProcessCanceledException` and Debugging
Sometimes, a PCE is thrown from `checkCanceled()` in the code inspected by a plugin developer during a debugging session.