---
title: "withExclusiveControl(_:)"
framework: Background Assets
role: symbol
role_heading: Instance Method
platforms: [iOS 16.1+, iPadOS 16.1+, Mac Catalyst 16.1+, macOS 13.0+, tvOS 18.4+, visionOS 2.4+]
path: "backgroundassets/badownloadmanager/withexclusivecontrol(_:)-1rf9w"
---

# withExclusiveControl(_:)

Attempts to acquire immediate, exclusive control over the download manager.

## Declaration

```swift
@backDeployed(before: iOS 27, macOS 27, tvOS 27, visionOS 27)
final func withExclusiveControl<ReturnType>(_ body: @escaping () throws -> sending ReturnType) async throws -> sending ReturnType
```

## Parameters

- `body`: A closure to execute with exclusive control over the download manager. Once the closure returns or throws, you lose exclusive control.

## Return Value

Return Value body’s return value.

## Discussion

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. note: When body throws or when exclusive control over the download manager can’t be acquired.
