<!--
{
  "availability" : [
    "iOS: 8.2.0 -",
    "iPadOS: 8.2.0 -",
    "macCatalyst: 13.1.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/ProcessInfo/performExpiringActivity(withReason:using:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSProcessInfo(im)performExpiringActivityWithReason:usingBlock:"
  },
  "title" : "performExpiringActivity(withReason:using:)"
}
-->

# performExpiringActivity(withReason:using:)

Performs the specified block asynchronously and notifies you if the process is about to be suspended.

```
func performExpiringActivity(withReason reason: String, using block: @escaping @Sendable (Bool) -> Void)
```

## Parameters

`reason`

A string used in debugging to indicate the reason the activity began. This parameter must not be `nil` or an empty string.

`block`

A block containing the work to be performed by the activity. The block has no return value and takes the following parameter:

- expired: A Boolean indicating whether the process is about to be suspended. If the value is <doc://com.apple.documentation/documentation/Swift/true>, the process is about to be suspended so you should take whatever steps are needed to stop in progress work. If it is <doc://com.apple.documentation/documentation/Swift/false>, start the planned tasks.

## Discussion

Use this method to perform tasks when your process is executing in the background. This method queues `block` for asynchronous execution on a concurrent queue. When your process is in the background, the method tries to take a task assertion to ensure that your block has time to execute. If it is unable to take a task assertion, or if the time allotted for the task assertion expires, the system executes your block with the parameter set to <doc://com.apple.documentation/documentation/Swift/true>. If it is able to take the task assertion, it executes the block and passes <doc://com.apple.documentation/documentation/Swift/false> for the expired parameter.

If your block is still executing and the system need to suspend the process, the system executes your block a second time with the `expired` parameter set to <doc://com.apple.documentation/documentation/Swift/true>. Your block must be prepared to handle this case. When the expired parameter is <doc://com.apple.documentation/documentation/Swift/true>, stop any in-progress tasks as quickly as possible.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)