Sometimes, I need some code to skip a run loop pass. For example, I'm closing a sheet that animates out and then run a heavy synchronous operation. To prevent the synchronous operation from making the animation stutter, I use DispatchQueue.main.async to defer the code to the next run loop. Example.
What would be the way to handle this now with the new concurrency features?
Is it even an issue anymore? If your synchronous operation isn’t @MainActor the system runs it on a separate thread now anyway doesn’t it? Maybe I misunderstood the WWDC sessions…
Isn’t having long-running operations on @MainActor a design flaw? “Never block the main thread.” is still an axiom in this new concurrency world right?
I didn't say long-running. I would recommend looking at the linked example as it makes it clearer: I'm closing a sheet that animates out. The closing action happens on the @MainActor. I don't control the animation as it's a NSOpenPanel. Immediately in the completion handler, I open another sheet (still in the @MainActor). If I don't put the new sheet opening call in a DispatchQueue.main.async, the first sheet closing animation stutters. Skipping a run loop pass usually fixes small animation issues like this.