---
title: "CFMessagePortInvalidate(_:)"
framework: corefoundation
role: symbol
role_heading: Function
path: "corefoundation/cfmessageportinvalidate(_:)"
---

# CFMessagePortInvalidate(_:)

Invalidates a CFMessagePort object, stopping it from receiving or sending any more messages.

## Declaration

```swift
func CFMessagePortInvalidate(_ ms: CFMessagePort!)
```

## Parameters

- `ms`: The message port to invalidate.

## Discussion

Discussion Invalidating a message port prevents the port from ever sending or receiving any more messages; the message port is not deallocated, though. If the port has not already been invalidated, the port’s invalidation callback function is invoked, if one has been set with CFMessagePortSetInvalidationCallBack(_:_:). The CFMessagePortContext  info information for ms is also released, if a release callback was specified in the port’s context structure. Finally, if a run loop source was created for ms, the run loop source is also invalidated.

## See Also

### Using a Message Port

- [CFMessagePortSendRequest(_:_:_:_:_:_:_:)](corefoundation/cfmessageportsendrequest(_:_:_:_:_:_:_:).md)
- [CFMessagePortSetDispatchQueue(_:_:)](corefoundation/cfmessageportsetdispatchqueue(_:_:).md)
