> ## Documentation Index
> Fetch the complete documentation index at: https://docs.xbox.com/llms.txt
> Use this file to discover all available pages before exploring further.

# XblMultiplayerManagerDoWork

> XblMultiplayerManagerDoWork

Maintains game state updates between the title and Multiplayer Manager (MPM).

## Syntax

```cpp theme={null}
HRESULT XblMultiplayerManagerDoWork(  
         const XblMultiplayerEvent** multiplayerEvents,  
         size_t* multiplayerEventsCount  
)  
```

### Parameters

*multiplayerEvents*   \_Deref\_out\_opt\_\
Type: const [XblMultiplayerEvent](https://docs.xbox.com/reference/live/xsapi-c/multiplayer_manager_c/structs/xblmultiplayerevent.md)\*\*

An array of multiplayer events for the game to handle. This is set to null if no multiplayer events occur during this update.

*multiplayerEventsCount*   \_Out\_\
Type: size\_t\*

The size of the `multiplayerEvents` array.

### Return value

Type: HRESULT

Returns `S_OK` on success, including when no events occurred. When there are no events, `multiplayerEvents` is set to null and `multiplayerEventsCount` is set to 0. Possible error codes include the following. This list isn't exhaustive.

| Return code | Description |
| - | - |
| E\_XBL\_NOT\_INITIALIZED | XSAPI or Multiplayer Manager isn't currently initialized. The initialization check runs before the arguments are validated. |
| E\_INVALIDARG | `multiplayerEvents` or `multiplayerEventsCount` is null. |

If either of these errors occurs, a non-null `multiplayerEvents` is set to null and `multiplayerEventsCount` isn't written.

## Remarks

Call [XblMultiplayerManagerInitialize](https://docs.xbox.com/reference/live/xsapi-c/multiplayer_manager_c/functions/xblmultiplayermanagerinitialize.md) before you call this function.

This function sends and receives game state updates between the title and Multiplayer Manager (MPM), returning an array of [XblMultiplayerEvent](https://docs.xbox.com/reference/live/xsapi-c/multiplayer_manager_c/structs/xblmultiplayerevent.md) structures that represent significant multiplayer events, such as remote players joining or leaving. You must call this function on a regular and frequent basis, such as once per frame, so that MPM can properly maintain game state. For more information, see [Multiplayer Manager overview](https://docs.xbox.com/services/xbox-services/multiplayer/mpm/live-multiplayer-manager-overview.md). \
The multiplayer events returned by this function are owned by MPM, and remain valid only until `XblMultiplayerManagerDoWork` is called again. In addition, the title must be thread-safe when calling `XblMultiplayerManagerDoWork`, because game state changes at the time this function is called. For example, if you're iterating through the list of members on a thread other than the one from which you're calling this function, the list may change when this function is called.

## Requirements

**Header:** multiplayer\_manager\_c.h

**Library:** Microsoft.Xbox.Services.142.C.lib or Microsoft.Xbox.Services.143.C.lib

## See also

[multiplayer\_manager\_c](https://docs.xbox.com/reference/live/xsapi-c/multiplayer_manager_c/multiplayer_manager_c_members.md)


## Related topics

- [Multiplayer Manager overview](https://docs.xbox.com/services/xbox-services/multiplayer/mpm/live-multiplayer-manager-overview.md)
- [XblMultiplayerManagerSetJoinability](https://docs.xbox.com/reference/live/xsapi-c/multiplayer_manager_c/functions/xblmultiplayermanagersetjoinability.md)
- [XblMultiplayerEvent](https://docs.xbox.com/reference/live/xsapi-c/multiplayer_manager_c/structs/xblmultiplayerevent.md)
- [Multiplayer Manager API overview](https://docs.xbox.com/services/xbox-services/multiplayer/mpm/concepts/live-multiplayer-manager-api-overview.md)
- [XblMultiplayerManagerInitialize](https://docs.xbox.com/reference/live/xsapi-c/multiplayer_manager_c/functions/xblmultiplayermanagerinitialize.md)
