> ## 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

封鎖執行，直到達到指定的主機狀態或發生逾時為止。

## 語法

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

<a id="parametersSection" />

### 參數

*address*\
類型：PCWSTR

\[in] 主機的位址。

*consoleState*\
類型：UINT32

\[in] 旗標的位元 OR 組合，表示主機目前的狀態。此參數支援下列旗標：

| 旗標 | 值 | 描述 |
| - | - | - |
| XTF\_SYSTEM\_OS\_READY | 0x0001 | System OS 已準備好進行 XBOX Tools Framework (XTF) 通訊。 |
| XTF\_TITLE\_OS\_READY | 0x0002 | Game OS 已準備好進行 XTF 通訊。\<br>此旗標相當於 [XtfGetTitleOSState](/zh-TW/reference/tools/xtf/xtfapi/functions/xtfgettitleosstate-xtfapi-xbox-windows-m) 函式所傳回的 `XTF_TITLESTATE_TITLEOSRUNNING` 和 `XTF_TITLESTATE_TITLENETWORK_READY` 旗標。 |
| XTF\_TITLE\_PROCESS\_READY | 0x0004 | 遊戲的處理序已準備好進行 XTF 通訊。\<br>此旗標相當於 `XtfGetTitleOSState` 函式所傳回的 `XTF_TITLESTATE_TITLERUNNING` 旗標。 |

*timeoutMS*\
類型：UINT32

\[in] 函式傳回 `ERROR_TIMEOUT` 之前的逾時 (以毫秒為單位)。

<a id="retvalSection" />

### 傳回值

類型：HRESULT

如果成功，則傳回 `S_OK`；否則會傳回下列其中一個 HRESULT 錯誤碼。

| 錯誤碼 | 描述 |
| - | - |
| ERROR\_TIMEOUT | *timeoutMS* 中指定的逾時已經過，但未達到 *consoleState* 中指定的狀態。 |
| E\_INVALIDARG | 傳入 *address* 或 *consoleState* 的值無效。 |

<a id="remarksSection" />

## 備註

此函式每 250 毫秒循環一次，根據 `consoleState` 中指定的狀態驗證主機的目前狀態。如果 `consoleState` 中指定的狀態在 `timeoutMS` 中指定的時間內與主機的目前狀態不符，函式會傳回 `ERROR_TIMEOUT`；否則，函式會停止循環並傳回 `S_OK`。如需 System OS 和 Game OS 的詳細資訊，如需完整的簡介，請參閱[什麼是 Microsoft Game Development Kit？(NDA 主題)](https://learn.microsoft.com/gaming/gdk/docs/gdk-dev/intro/introduction)。

## 需求

**標頭：** xtfapi.h

**程式庫：** XtfApi.lib

**支援的平台：** Windows (適用於 XBOX 主機工具)

<a id="seealsoSection" />

## 另請參閱

[XTF 傳輸錯誤 (NDA 主題)](/zh-TW/tools/tools-console/commandlinetools/xtf-transport-errors)\
[其他 Xtf API](/zh-TW/reference/tools/xtf/xtfapi/atoc-xtfapi)


## Related topics

- [Wait](/zh-TW/reference/graphics/d3d12/interfaces/id3d12commandqueue/methods/id3d12commandqueue_wait_public.md)
- [IXtfRemoteRunClient::Run 方法](/zh-TW/reference/tools/xtf/xtfremoterun/classes/IXtfRemoteRunClient/methods/ixtfremoterunclient_run.md)
- [XtfGetTitleOSState](/zh-TW/reference/tools/xtf/xtfapi/functions/xtfgettitleosstate-xtfapi-xbox-windows-m.md)
- [XGameStreamingUnregisterConnectionStateChanged](/zh-TW/reference/system/xgamestreaming/functions/xgamestreamingunregisterconnectionstatechanged.md)
- [XtfCreateConsoleManager](/zh-TW/reference/tools/xtf/xtfconsolemanager/methods/xtfcreateconsolemanager-xtfconsolemanager-xbox-microsoft-m.md)
