From 268e780d5c1ed89593ef0a9d109abfc0bae6054f Mon Sep 17 00:00:00 2001 From: Karol Lewandowski Date: Thu, 13 Feb 2025 11:42:25 +0100 Subject: [PATCH] coroutine_execution_contexts.md: Add a simple example to clarify what the main usage pattern is --- .../coroutines/coroutine_execution_contexts.md | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/topics/basics/architectural_overview/coroutines/coroutine_execution_contexts.md b/topics/basics/architectural_overview/coroutines/coroutine_execution_contexts.md index bd0761c16..41ff70f1f 100644 --- a/topics/basics/architectural_overview/coroutines/coroutine_execution_contexts.md +++ b/topics/basics/architectural_overview/coroutines/coroutine_execution_contexts.md @@ -51,9 +51,21 @@ Therefore, if their behavior is required, [switch to a blocking context](#suspen - [`ProgressStep`](%gh-ic%/platform/util/progress/src/impl/ProgressStep.kt) - a step-based progress reporting (see its KDoc for details) - [`RawProgressReporter`](%gh-ic%/platform/util/progress/src/RawProgressReporter.kt) - a raw text, details, and fraction reporting (invoked via [`reportRawProgress()`](%gh-ic%/platform/util/progress/src/steps.kt)) -Any [`report*Progress()`](%gh-ic%/platform/util/progress/src/steps.kt) function should be used inside [`with*Progress()` or `runWithModalProgressBlocking()`](%gh-ic%/platform/progress/shared/src/tasks.kt). +Any [`report*Progress()`](%gh-ic%/platform/util/progress/src/steps.kt) function must be used inside [`withBackgroundProgress()`, `withModalProgress()`, or `runWithModalProgressBlocking()`](%gh-ic%/platform/progress/shared/src/tasks.kt). Otherwise, if there is no reporter in the context, using `report*Progress()` will have no effect. +Example: + +```kotlin +withBackgroundProgress(...) { // or withModalProgress/runWithModalProgressBlocking + // ... + reportProgress { reporter -> // or another report*Progress + // do tasks and report progress + } + // ... +} +``` + ### Switching to Other Contexts {#suspending-context-switching-to-other-contexts}