mirror of
https://github.com/JetBrains/intellij-sdk-code-samples.git
synced 2025-07-30 02:07:50 +08:00
coroutine_execution_contexts.md: Add a simple example to clarify what the main usage pattern is
This commit is contained in:
parent
33dbce0bb0
commit
268e780d5c
@ -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)
|
- [`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))
|
- [`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.
|
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
|
### Switching to Other Contexts
|
||||||
{#suspending-context-switching-to-other-contexts}
|
{#suspending-context-switching-to-other-contexts}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user