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

# XtfWaitForConsoleState

> XtfWaitForConsoleState

# XtfWaitForConsoleState

Blocks execution until either the specified console states are reached or a timeout occurs.

## Syntax

```cpp theme={null}
HRESULT XtfWaitForConsoleState(  
         PCWSTR address,  
         UINT32 consoleState,  
         const UINT32 timeoutMS  
)  
```

### Parameters

*address*\
Type: PCWSTR

\[in] The address of the console.

*consoleState*\
Type: UINT32

\[in] A bitwise-OR combination of flags that indicate the current state of the console. This parameter supports the following flags:

| Flag | Value | Description |
| - | - | - |
| XTF\_SYSTEM\_OS\_READY | 0x0001 | The System OS is ready XBOX Tools Framework (XTF) communications. |
| XTF\_TITLE\_OS\_READY | 0x0002 | The Game OS is ready for XTF communications.\<br>This flag is equivalent to the `XTF_TITLESTATE_TITLEOSRUNNING` and `XTF_TITLESTATE_TITLENETWORK_READY` flags returned by the [XtfGetTitleOSState](/reference/tools/xtf/xtfapi/functions/xtfgettitleosstate-xtfapi-xbox-windows-m) function. |
| XTF\_TITLE\_PROCESS\_READY | 0x0004 | The process for the game is ready for XTF communications.\<br>This flag is equivalent to the `XTF_TITLESTATE_TITLERUNNING` flag returned by the `XtfGetTitleOSState` function. |

*timeoutMS*\
Type: UINT32

\[in] The timeout, in milliseconds, before the function returns `ERROR_TIMEOUT`.

### Return value

Type: HRESULT

Returns `S_OK` if successful; otherwise, returns one of the following HRESULT error codes.

| Error code | Description |
| - | - |
| ERROR\_TIMEOUT | The timeout specified in *timeoutMS* has elapsed and the states specified in *consoleState* were not reached. |
| E\_INVALIDARG | The values passed into *address* or *consoleState* were not valid. |

## Remarks

This function loops every 250 milliseconds, validating the current state of the console against the states specified in `consoleState`. If the states specified in `consoleState` don't match the current state of the console within the time specified in `timeoutMS`, the function returns `ERROR_TIMEOUT`; otherwise, the function stops looping and returns `S_OK`. For more information about the System OS and Game OS, see For a complete introduction, see [What is the Microsoft Game Development Kit? (NDA topic)](https://learn.microsoft.com/gaming/gdk/docs/gdk-dev/intro/introduction).

## Requirements

**Header:** xtfapi.h

**Library:** XtfApi.lib

**Supported platforms:** Windows (for XBOX console tools)

## See also

[XTF Transport Errors (NDA topic)](/tools/tools-console/commandlinetools/xtf-transport-errors)\
[Additional Xtf APIs](/reference/tools/xtf/xtfapi/atoc-xtfapi)


## Related topics

- [Wait](/reference/graphics/d3d12/interfaces/id3d12commandqueue/methods/id3d12commandqueue_wait_public.md)
- [XtfGetTitleOSState](/reference/tools/xtf/xtfapi/functions/xtfgettitleosstate-xtfapi-xbox-windows-m.md)
- [QueryExecutionState](/reference/tools/xtf/xtfapplication/classes/IXtfApplicationClient/methods/queryexecutionstate-ixtfapplicationclient-xtfapplication-xbox-microsoft-m.md)
- [ConnectGamepad](/reference/tools/xtf/xtfinput/classes/IXtfInputClient/methods/connectgamepad-ixtfinputclient-xtfinput-xbox-windows-m.md)
- [XtfCreateApplicationClient](/reference/tools/xtf/xtfapplication/methods/xtfcreateapplicationclient-xtfapplication-xbox-microsoft-m.md)
