<!--
{
  "availability" : [
    "iOS: 12.0.0 -",
    "iPadOS: 12.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.14.0 -",
    "tvOS: 12.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Metal",
  "identifier" : "/documentation/Metal/MTLCommandBuffer/encodeWaitForEvent(_:value:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Metal"
    ],
    "preciseIdentifier" : "c:objc(pl)MTLCommandBuffer(im)encodeWaitForEvent:value:"
  },
  "title" : "encodeWaitForEvent(_:value:)"
}
-->

# encodeWaitForEvent(_:value:)

Encodes a command into the command buffer that pauses the GPU from running the buffer’s subsequent passes until the event equals or exceeds a value.

```
func encodeWaitForEvent(_ event: any MTLEvent, value: UInt64)
```

## Parameters

`event`

An [`MTLEvent`](/documentation/Metal/MTLEvent) instance the GPU driver waits for between passes as it runs the command buffer.

    If     `event`     is an [`MTLSharedEvent`](/documentation/Metal/MTLSharedEvent)     instance, a command buffer from any GPU device can signal this command buffer. Otherwise, only command buffers from the same GPU device can signal this command buffer.

`value`

The event’s smallest value that allows the GPU to continue running the remaining passes in the command buffer.

## Discussion

This method prevents the GPU from starting the next pass in the command buffer until another command buffer signals `event` (see [`encodeSignalEvent(_:value:)`](/documentation/Metal/MTLCommandBuffer/encodeSignalEvent(_:value:)).

A command buffer can instruct the GPU to wait for an event only between passes, not within a pass. If a command buffer has an active encoder, finish using the encoder, call its [`endEncoding()`](/documentation/Metal/MTLCommandEncoder/endEncoding()) method, and then call this method before creating another encoder.

When the GPU device reaches the wait command that this method encodes into the buffer, it checks the event’s current value. If the event’s value — which increases monotonically — is less than the `value` parameter, the GPU waits before running the next pass in the buffer. The GPU starts the next pass when the event signals a value that’s equal to or greater than the `value` parameter (see [`encodeSignalEvent(_:value:)`](/documentation/Metal/MTLCommandBuffer/encodeSignalEvent(_:value:))). However, If the event’s value is already greater than or equal to the `value` parameter, the GPU immediately starts the next pass without waiting.

---

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)