ursus
01/03/2022, 9:47 PMbaxter
01/03/2022, 10:06 PMimmediate
if it's possible the thread backing the coroutine is already in main, and should be run at that point in time. Else, I let whatever is handling the main thread to schedule as necessary.ursus
01/03/2022, 10:26 PMbaxter
01/03/2022, 10:47 PMimmediate
, you take finer control over what runs first.FunkyMuse
01/03/2022, 11:30 PMMartin Rajniak
01/04/2022, 11:17 AM// Get a handler that can be used to post to the main thread
Handler mainHandler = new Handler(context.getMainLooper());
Runnable myRunnable = new Runnable() {
@Override
public void run() {....} // This is your code
};
<http://mainHandler.post|mainHandler.post>(myRunnable);
This was used to call main thread from other thread.
I would compare it with Dispatchers.Main
since you don't need to execute immediately.
Would you agree?