Is Task {…} in a @MainActor method guaranteed to run in the next run loop cycle?

Hmmm, so in your specific example yes, but only via a rather brittle specific way this function is written.

Because there is no suspension point here this function test() will run to completion until anything else can run on it. If you had ANY await in this function, the order would not be guaranteed anymore.

I was answering effectively the same question over here a day ago or so: Task: Is order of task execution deterministic? - #60 by jmjauer which you might find useful

edited: misread your example

2 Likes