Assuming the task (Task) is triggered from a SwiftUI button action, adding @MainActor won't change anything because SwiftUI View is now MainActor-ed. With or without specifying @MainActor, the task will start from the main actor, do deleteEvent in the database manager actor, and come back to the main actor to run dismiss. Regarding the delay, do you have a minimal project that reproduces the issue? If yes, I'd be interested in taking a look. I am wondering if deleteEvent calls other async methods, which eventually leads to dismiss being called before the deletion is done. Without looking into a reproducible case, however, I can't say anything for sure. Best, —— Ziqiao Chen Worldwide Developer Relations.
Topic:
App & System Services
SubTopic:
iCloud & Data
Tags: