background_processes.md: Add a tip for running backgroundable tasks under a custom progress indicator

This commit is contained in:
Karol Lewandowski 2025-01-14 12:24:39 +01:00
parent 20cac10a3a
commit 429e9698b5

View File

@ -43,7 +43,7 @@ The key classes are:
### Starting ### Starting
Background processes encapsulated within `Task` should be run with queueing them. Background processes encapsulated within `Task` can be run with queueing them.
Example: Example:
<tabs group="languages"> <tabs group="languages">
@ -73,6 +73,14 @@ new Task.Backgroundable(project, "Synchronizing data", true) {
</tab> </tab>
</tabs> </tabs>
> To run a backgroundable task under a custom progress indicator, for example, `EmptyProgressIndicator` to hide progress, use:
> ```kotlin
> ProgressManager.getInstance()
> .runProcessWithProgressAsynchronously(
> backgroundableTask, EmptyProgressIndicator())
> ```
> Note that hiding progress from users should be avoided as it may break the UX.
`ProgressManager` also allows running `Runnable` and `Computable` instances not wrapped within `Task` with several `run*()` methods. `ProgressManager` also allows running `Runnable` and `Computable` instances not wrapped within `Task` with several `run*()` methods.
Example: Example: