Questions tagged [suspend]
469 questions
282
votes
10 answers
What does the suspend function mean in a Kotlin Coroutine?
I'm reading Kotlin Coroutine and know that it is based on suspend function. But what does suspend mean?
Can Coroutine or function get suspended?
From https://kotlinlang.org/docs/reference/coroutines.html
Basically, coroutines are computations that…

onmyway133
- 45,645
- 31
- 257
- 263
70
votes
2 answers
Run one command after another, even if I suspend the first one (Ctrl-z)
I know in bash I can run one command after another by separating them by semicolons, like
$ command1; command2
Or if I only want command2 to run only if command1 succeeds, using &&:
$ command1 && command2
This works, but if I suspend command1…

asmeurer
- 86,894
- 26
- 169
- 240
32
votes
1 answer
call a suspend function inside a normal function
I want to call blocking a suspend function in a normal function, but does not block Thread to finishing suspend function and then return Response
override fun intercept(chain: Interceptor.Chain): Response {
// getSession is a suspend function
…

beigirad
- 4,986
- 2
- 29
- 52
27
votes
6 answers
Difference between CoroutineScope and coroutineScope in Kotlin
Can anyone give clarity between functions CoroutineScope() and coroutineScope()?
When I tried to check in source, I found that both of them are functions of CoroutineScope.kt. Additionally, coroutineScope() is suspend function while other one is…

Kushal
- 8,100
- 9
- 63
- 82
27
votes
4 answers
How delete suspended app from google play developer console?
I have app uploaded to google play store, but application has suspended from the Google Play Store due to some violation of the impersonation or deceptive behavior provisions of the Content Policy. In google console I am able see as below…

sandeepmaaram
- 4,191
- 2
- 37
- 42
25
votes
2 answers
What is suspendCoroutine?
I am a beginner studying coroutines.
Not exactly, but I have a little understanding of what a coroutine is.
The suspend function is also difficult, but with a little understanding.
I'm studying step by step, but there are parts I don't…

ybybyb
- 1,385
- 1
- 12
- 33
23
votes
2 answers
Correct way to suspend coroutine until Task is complete
I've recently dove into Kotlin coroutines
Since I use a lot of Google's libraries, most of the jobs is done inside Task class
Currently I'm using this extension to suspend coroutine
suspend fun awaitTask(task: Task): T = suspendCoroutine {…

Dmytro Rostopira
- 10,588
- 4
- 64
- 86
22
votes
2 answers
What is the appropriate way of calling suspending functions inside a suspendCoroutine block?
I need to call a suspending function inside a suspendCoroutine block, before I call continuation.resume().
What is the appropriate way of doing that?
private suspend fun someFunction() = suspendCoroutine { cont ->
//...
val myResult =…

bernardo.g
- 826
- 1
- 12
- 27
20
votes
2 answers
Parallel request with Retrofit, Coroutines and Suspend functions
I'm using Retrofit in order to make some network requests. I'm also using the Coroutines in combination with 'suspend' functions.
My question is: Is there a way to improve the following code. The idea is to launch multiple requests in parallels and…

Valentin
- 5,379
- 7
- 36
- 50
16
votes
3 answers
How to pause/suspend a thread then continue it?
I am making an application in C# which uses a winform as the GUI and a separate thread which is running in the background automatically changing things. Ex:
public void Run()
{
while(true)
{
printMessageOnGui("Hey");
…

rvk
- 737
- 3
- 9
- 23
14
votes
1 answer
PyCharm - how to suspend all threads
We're using PyCharm 5.0.1 for multi-thread debugging.
When it stops at a break point, only the specific thread stops while all the other continue. This makes it hard to "freeze the moment" and check params values, and the current state of the other…

user3139774
- 1,295
- 3
- 13
- 24
13
votes
2 answers
Why is adding SuspendLayout and ResumeLayout reducing performance?
I need to add a lot of controls to a parent control.
But I find if I add ParentControl.SuspendLayout and ParentControl.ResumeLayout before and after I add those controls to the parent, I use stopwatch to measure the ticks:
If I remove the code…

spspli
- 3,128
- 11
- 48
- 75
12
votes
1 answer
How to prevent an android device from entering sleep (via adb command shell)
I am working on an embedded board with android on it. Unfortunately I cannot use the display as I dont have a supporting display device (LVDS display).
Problem :
Everytime i bootup the device, the device goes into sleep after some time.
Restarting…

Sandeep
- 18,356
- 16
- 68
- 108
11
votes
4 answers
XCTest UI Testing - How to close and open an app without relaunch?
I want to make my app to go to background, and then comeback to the foreground.
To make an app to go background: XCUIDevice.shared().press(XCUIDeviceButton.home)
To terminate an app(force tap): XCUIApplication().terminate()
To launch the app:…

Confused
- 3,846
- 7
- 45
- 72
11
votes
1 answer
Real-time aware sleep() call?
I've written a utility to talk to TomTom GPS watches over Bluetooth, and am trying to make it run nicely as a run-and-forget background daemon.
The program periodically communicates with the GPS device and then sleeps for a while until it's needed…

Dan Lenski
- 76,929
- 13
- 76
- 124