withExclusiveControl(_:)
Attempts to acquire immediate, exclusive control over the download manager.
Declaration
@backDeployed(before: iOS 27, macOS 27, tvOS 27, visionOS 27)
final func withExclusiveControl<ReturnType>(_ body: @escaping () throws -> sending ReturnType) async throws -> sending ReturnTypeParameters
- body:
A closure to execute with exclusive control over the download manager. Once the closure returns or throws, you lose exclusive control.
Return Value
body’s return value.
Discussion
To avoid races between your main app and your downloader extension, perform operations on the download manager—e.g., fetching current downloads, scheduling new downloads, etc.—while maintaining exclusive control over it. Unlike withExclusiveControl(_:), this method waits for exclusive control to be acquired and then relinquished before it returns.