Passing closure as a 'sending' parameter risks causing data races between code in the current task and concurrent execution
10:12 07 May 2026

I'm keeping most information in an actor and I would like to save also a closure in it that I get from

func application(
        _ application: UIApplication,
        handleEventsForBackgroundURLSession identifier: String,
        completionHandler: @escaping () -> Void)

by using code:

Task.init{
                await GeoreferenceQueue.shared.setBackgroundCompletionHandler(completionHandler)
            }

yet I receive error:

Passing closure as a 'sending' parameter risks causing data races between code in the current task and concurrent execution of the closure

and

Sending task-isolated 'completionHandler' to actor-isolated instance method 'setBackgroundCompletionHandler' risks causing data races between actor-isolated and task-isolated uses

swift actor