From 429e9698b59afcdbfade12fe521ed17082ea7da3 Mon Sep 17 00:00:00 2001 From: Karol Lewandowski Date: Tue, 14 Jan 2025 12:24:39 +0100 Subject: [PATCH] background_processes.md: Add a tip for running backgroundable tasks under a custom progress indicator --- .../architectural_overview/background_processes.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/topics/basics/architectural_overview/background_processes.md b/topics/basics/architectural_overview/background_processes.md index 67b05216a..0bc7c59de 100644 --- a/topics/basics/architectural_overview/background_processes.md +++ b/topics/basics/architectural_overview/background_processes.md @@ -43,7 +43,7 @@ The key classes are: ### Starting -Background processes encapsulated within `Task` should be run with queueing them. +Background processes encapsulated within `Task` can be run with queueing them. Example: @@ -73,6 +73,14 @@ new Task.Backgroundable(project, "Synchronizing data", true) { +> 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. Example: